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
- :
- Returning a string from c++ dll function
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
Jun 01, 2015
10:21 AM
Returning a string from c++ dll function
I am trying return a programmatically built string from a c++ function to InstallScript. For example, appending and replacing (sub-strings) a string that I return from another function.
Code in c++
code in InstallScript
I have tried altering my c++ function so that it returns a string instead of LPCSTR, but did NOT change any code in InstallScript. This resulted in a run-time error in InstallShield.
How can I pass a string back to InstallScript?
Code in c++
SQLHELPER_API LPCSTR GetAvailableAppName(LPCSTR appNameP)
{
//return "this works just fine";
std::string newAppName = "I work, maybe?";
LPCSTR returnVal = newAppName.c_str();
return returnVal; //this will either return an empty string or a mishmash of the string
}
code in InstallScript
prototype cdecl string SqlHelper.GetAvailableAppName(BYREF string);
string ERPORTALAPP;
ERPORTALAPP = GetAvailableAppName("eRPortalApp"); //returns an empty string or a mishmash of the string
I have tried altering my c++ function so that it returns a string instead of LPCSTR, but did NOT change any code in InstallScript. This resulted in a run-time error in InstallShield.
How can I pass a string back to InstallScript?
(1) Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Jun 03, 2015
02:08 PM
For APIs used across DLL boundaries, typically the best approach is for the API to accept a pointer to a buffer (and a size of that buffer) and fill it in. Many Windows API functions, like GetEnvironmentVariable or MsiGetProperty work this way, and these are fairly easy to call from InstallScript.
![](/skins/images/8C9D13A71C7F7695F3262372C0172D68/responsive_peak/images/icon_anonymous_message.png)