This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- strings in c++ dll (unicode dll with visual c++)
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 20, 2010
11:10 AM
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 :
Everything is ok.
So the link between my dll and my InstallShield project is ok.
But if my function use "string" instead of int :
There is a problem :
I use this dll in a custom action created with the wizard :
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.
(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 :
* return type = STRING
* returnproperty = RESULT
* argument :
Type = STRING ;
Source = InProperty ;
Value = COMPANYNAME
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.
24 Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 21, 2010
01:55 AM
😞
nobody can help me ...
nobody can help me ...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 21, 2010
12:37 PM
First off, if the string you refer to in your c++ code is std::string, you'll have all sorts of problems with this approach; it's best to use least common denominator types when interfacing between different languages. In this case, you should use something like LPCSTR (aka char const*) for your input parameter; I'm not sure how to suggest returning the string, except to use it as an in/out parameter (LPSTR aka char*).
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 03, 2010
03:22 AM
Hello MichaelU, and hello everybody
Thank you very much for your help MichaelU. My dll works now, every things are OK.
If somebody wants to know the code which is OK :
Here, my function in my c++ program :
And here, the Function signature in my installshield custom action :
[HTML]STRING=[RESULT]ScriptInstall::get_Action(in STRING=[COMPANYNAME])[/HTML]
Thank you very much !
Thank you very much for your help MichaelU. My dll works now, every things are OK.
If somebody wants to know the code which is OK :
Here, my function in my c++ program :
typedef char* LPSTR;
LPSTR get_Action(LPSTR resultat)
{
return resultat;
}
And here, the Function signature in my installshield custom action :
[HTML]STRING=[RESULT]ScriptInstall::get_Action(in STRING=[COMPANYNAME])[/HTML]
Thank you very much !
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 07, 2010
03:47 AM
Hello every body
My dll is not so OK that I thought. 😞
If I use this code :
I have a property "RESULT" which have a value before the dll function
And my dll function returns this value.
Every thing is OK.
But If I try to change this value in my dll function, there is a probleme :
I have try with different types of strings :
LPSTR, LPWSTR, LPCWSTR ...
There isn't a good solution.
So, I try something else (function returns void):
And in InstallShield , I have tried :
[CODE]STRING=void ScriptInstall::get_Action(out STRING=[RESULT])[/CODE]
[CODE]STRING=void ScriptInstall::get_Action(inout STRING=[RESULT])[/CODE]
But there is not a good result.
Is there someone who can help me ?
Is there an example of C++ dll which works correctly with InstallShield and which modify a string property ?
Have a nice day.
My dll is not so OK that I thought. 😞
If I use this code :
typedef char* LPSTR;
LPSTR get_Action(LPSTR resultat)
{
return resultat;
}
I have a property "RESULT" which have a value before the dll function
And my dll function returns this value.
Every thing is OK.
But If I try to change this value in my dll function, there is a probleme :
typedef char* LPSTR;
LPSTR get_Action(LPSTR resultat)
{
resultat="test";
return resultat;
}
I have try with different types of strings :
LPSTR, LPWSTR, LPCWSTR ...
There isn't a good solution.
So, I try something else (function returns void):
typedef char* LPSTR;
void get_Action(LPSTR resultat)
{
resultat="test";
}
And in InstallShield , I have tried :
[CODE]STRING=void ScriptInstall::get_Action(out STRING=[RESULT])[/CODE]
[CODE]STRING=void ScriptInstall::get_Action(inout STRING=[RESULT])[/CODE]
But there is not a good result.
Is there someone who can help me ?
Is there an example of C++ dll which works correctly with InstallShield and which modify a string property ?
Have a nice day.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 08, 2010
02:35 AM
nobody can help me ...
😞
😞
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 09, 2010
12:39 AM
I have not found solution yet. 😞
If someone have an idea...
If someone have an idea...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 09, 2010
04:49 AM
ametisse wrote:
I have not found solution yet. 😞
If someone have an idea...
Maybe I can help you:
DLL
extern "C" CString WINAPI CheckDll(LPCTSTR lpszTest)
{
CString test;
test.Format("%s TEST", lpszTest);
return test;
}
IS function:
prototype STRING IsHelp.CheckDll(LPSTR);
export prototype STRING DllTest(LPSTR);
function STRING DllTest(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 = CheckDll(sTemp);
UnUseDLL("C:\\Temp\\IsHelp.dll");
return ret;
end;
IS function call:
sTeststring = DllTest(&sTeststring);
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 10, 2010
03:50 AM
Hello,
Thank you for your help MrTree. But I did not manage to make a correct code.
How the "IS function" must be done ? (custom action > VBScript code ?)
I have try like that :
Dll code :
with the def file :
IS function in a custom action (VBScript code) :
(I have tried with and without the last row, but there is the same problem in these two cases.)
And I call the custom action on the "next" button of the dialog box "Customer informations".
Before I try this idea, when I launched the install, I had an error message. Now the install is stopped without message error. So I think there is a problem in InstallShield (not in the dll, or both).
I have never use scripts in InstallShield . Can you help me ?
Thank you every body.
Thank you for your help MrTree. But I did not manage to make a correct code.
How the "IS function" must be done ? (custom action > VBScript code ?)
I have try like that :
Dll code :
#include "atlstr.h"
#include "cstringt.h"
extern "C" CString WINAPI CheckDll(LPCTSTR lpszTest)
{
CString test;
test.Format(L"%s TEST", lpszTest);
return test;
}
with the def file :
LIBRARY "ScripInstall"
EXPORTS
CheckDll @1
IS function in a custom action (VBScript code) :
prototype STRING ScripInstall.CheckDll(LPSTR);
export prototype STRING DllTest(LPSTR);
function STRING DllTest(sTemp)
int nResult;
STRING ret;
STRING test;
begin
nResult = UseDLL("Z:\\FichiersInstallCeraSlice\\ScriptDLL\\ScripInstall.dll");
if(nResult != 0) then
MessageBox("Unable to load ScripInstall.dll.", SEVERE);
exit;
endif;
ret = CheckDll(sTemp);
UnUseDLL("Z:\\FichiersInstallCeraSlice\\ScriptDLL\\ScripInstall.dll");
return ret;
end;
session.property("RESULTAT") = DllTest(&(session.property("RESULTAT")));
(I have tried with and without the last row, but there is the same problem in these two cases.)
And I call the custom action on the "next" button of the dialog box "Customer informations".
Before I try this idea, when I launched the install, I had an error message. Now the install is stopped without message error. So I think there is a problem in InstallShield (not in the dll, or both).
I have never use scripts in InstallShield . Can you help me ?
Thank you every body.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 10, 2010
07:18 AM
I think that should work:
DLL cpp
DLL def
IS call
IS function
DLL cpp
#include "stdafx.h"
#include "atlbase.h"
extern "C" LPCTSTR WINAPI CheckDll(LPCTSTR lpszTest)
{
CString test;
test.Format("%s TEST", lpszTest);
return test;
}
DLL def
LIBRARY IsHelp
EXPORTS
CheckDll
IS call
function OnFirstUIBefore()
STRING sFilename;
POINTER pFilename;
begin
sFilename = "something";
pFilename = &sFilename;
sFilename = DllTest(pFilename);
MessageBox(sFilename, INFORMATION);
exit;
IS function
prototype STRING IsHelp.CheckDll(LPSTR);
export prototype STRING DllTest(LPSTR);
function STRING DllTest(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 = CheckDll(sTemp);
UnUseDLL("C:\\Temp\\IsHelp.dll");
return ret;
end;
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 10, 2010
10:05 AM
Hi, thank you for your help MrTree.
But I don't manage to do something right.
Have you test your solution ?
If yes, what soft have you used to do the dll?
Thank you very much.
But I don't manage to do something right.
Have you test your solution ?
If yes, what soft have you used to do the dll?
Thank you very much.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 11, 2010
04:39 AM
Hi MrTree, (and Hi every body too)
Thank you very much MrTree because now, I know that the dll I use is ok and I can search what is the problem in IS (because it doesn't work for me)
I think I have not understand something about the way to write the IS function, and to call it in IS.
For me there are differents ways to do that :
1- Doing a custom action with the custom action wizard

2- Use install script
(I have not tried with installscript, because I don't know how to do.)
What solution do you use to have something which works correctly ?
Thank you very much MrTree. 😮
Thank you very much MrTree because now, I know that the dll I use is ok and I can search what is the problem in IS (because it doesn't work for me)
I think I have not understand something about the way to write the IS function, and to call it in IS.
For me there are differents ways to do that :
1- Doing a custom action with the custom action wizard

2- Use install script
(I have not tried with installscript, because I don't know how to do.)
What solution do you use to have something which works correctly ?
Thank you very much MrTree. 😮
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 11, 2010
06:56 AM
I think these informations are important :
I'm using InstallShield 2010 Professional Edition
And my project is a basic MSI project
I'm using InstallShield 2010 Professional Edition
And my project is a basic MSI project
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 11, 2010
07:42 AM
Hi,
I think I can't change the type of my project (this one already existe)
There are very much things that are already done, so it's not possible to change it 😞
I think I can't change the type of my project (this one already existe)
There are very much things that are already done, so it's not possible to change it 😞
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 11, 2010
09:52 AM
Hi MrTree.
Thank you for this link. I haven't seen it.
I think it's a new idea to use. But I don't know how to do.
I'm searching. 😞
Thank you
Thank you for this link. I haven't seen it.
I think it's a new idea to use. But I don't know how to do.
I'm searching. 😞
Thank you
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 14, 2010
01:22 AM
Hi everybody,
My problem is not resolved yet.
My problem isn't to manage to use my dll in my basic MSI IS project, but only to use strings in this dll.
So I have try every possibilities you say me but the problem is always the same. I manage to use a function like that in my dll :
Or a function like that (with no modification of the string value in the function :
But if I try to use this function, (with the same way) :
It does'nt work.
Is somebody who knows how to use a function (in a dll) which use strings ?
Thank you very much.
My problem is not resolved yet.
My problem isn't to manage to use my dll in my basic MSI IS project, but only to use strings in this dll.
So I have try every possibilities you say me but the problem is always the same. I manage to use a function like that in my dll :
int myFunc (int value)
{
return (value+2);
}
Or a function like that (with no modification of the string value in the function :
typedef char* LPSTR;
LPSTR test(LPSTR val)
{
return val;
}
But if I try to use this function, (with the same way) :
typedef char* LPSTR;
LPSTR test(LPSTR val)
{
LPSTR res ="";
return res;
}
It does'nt work.
Is somebody who knows how to use a function (in a dll) which use strings ?
Thank you very much.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 14, 2010
07:56 AM
you only attached the projectfiles in your zip, there is no code -> helps not.
If your DLL looks like this:
and you call it correct from IS it will work.
If your DLL looks like this:
#include "stdafx.h"
#include "atlbase.h"
extern "C" LPCTSTR WINAPI CheckDll(LPCTSTR lpszTest)
{
CString test;
test = "This is the test of";
test.Format("%s %s", test, lpszTest);
return test;
}
and you call it correct from IS it will work.
