cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ametisse
Level 5

strings in c++ dll (unicode dll with visual c++)

Hello every body,

(Sorry for my bad english... :rolleyes: )

I'm trying to use a funtion which is in my c++ dll.
If my function is something like that :
int nameFunc (int myValue)
{
return myValue;
}

Everything is ok.
So the link between my dll and my InstallShield project is ok.

But if my function use "string" instead of int :
string nameFunc (string myValue)
{
return myValue;
}

There is a problem :
the dll being called encountered a problem


I use this dll in a custom action created with the wizard :
-> name

-> call a function in a standard dll

-> stored in a binary table

-> function def :

* name = nameFunc
* argument :
Type = STRING ;
Source = InProperty ;
Value = COMPANYNAME

* return type = STRING
* returnproperty = RESULT


I have done very much searches about this problem. I have understood that my dll must be done in unicode to accept strings. But I don't know how I can do that with visual C++ (I have done this dll myself and I can change it if it's necessary)

Is there someone who can help me to do a good dll with VisualStudio c++ in order to use it (with strings) in InstallShield ?

Thank you.
Labels (1)
0 Kudos
(24) Replies
ametisse
Level 5

Hi MrTree,

Yes I attach a zip with 3 elements :
- my dll
- my visual studio project (for the DLL) with the code
- my IS project

I had try your code, but I think our parameters are differents in the visual studio project.
(I had try with your dll, do you remember?)

So I have decided to stop my search about this probleme. I will change the process of my installation to use only numbers instead of strings. (I will use a code as result of my dll function, and in IS, I will "traduct" this code to know what to do)

Thank you very much for your help.
0 Kudos
MrTree
Level 6

You attached a Zip with three folders, each of them include annother zip with only one file. The .sln (only the visual studio solution, no source), the dll itself and the .ism (the Installshield solution)

I attached my dll (the whole VS Project) with annother function, it works for me in Installscript MSI with these calls:

// DLLTest
stmp = "something";
pFilename = &stmp;
stmp = CheckGetStringFromDll(pFilename);
MessageBox(stmp, INFORMATION);

nResult = CheckGetNumberFromDll(5);
NumToStr(stmp, nResult);
MessageBox(stmp, INFORMATION);



Methods:
function STRING CheckGetStringFromDll(sTemp)
int nResult;
STRING ret;
STRING test;
begin
nResult = UseDLL("C:\\Temp\\IsHelp.dll");

if(nResult != 0) then
MessageBox("Unable to load IsHelp.dll.", SEVERE);
exit;
endif;

ret = GetStringFromDll(sTemp);
UnUseDLL("C:\\Temp\\IsHelp.dll");

return ret;
end;


prototype NUMBER IsHelp.GetNumberFromDll(NUMBER);
export prototype NUMBER CheckGetNumberFromDll(NUMBER);

function NUMBER CheckGetNumberFromDll(nTemp)
NUMBER nResult, ret;
begin
nResult = UseDLL("C:\\Temp\\IsHelp.dll");

if(nResult != 0) then
MessageBox("Unable to load IsHelp.dll.", SEVERE);
exit;
endif;

ret = GetNumberFromDll(nTemp);
UnUseDLL("C:\\Temp\\IsHelp.dll");

return ret;
end;
0 Kudos
ametisse
Level 5

Hi,

:rolleyes: I thought that the .sln contain sources too, sorry.

The difference between your IS project and mine is that mine isn't InstallScript project but Basic MSI project. And I can't change that.

Today, I have done the other solution with numbers intead of strings. I think every thing would be ok.

Thank you very much for your help MrTree.
Have a nice day
0 Kudos
BuvinJ
Level 2

0 Kudos