Page 1 of 1
msi handle to c++ custom action
Posted: Thu Nov 06, 2008 12:38 am
by allensm
we have several c++ msi custom actions that we used with installshield. Since we are looking to migrate our installs over to installaware, I am running into one problem. It's not immediately obvious how to get the MSI Handle that I need to get and set parms within the c++ custom action. I don't see in the documentation how to do this either.
Posted: Thu Nov 06, 2008 9:58 am
by jsmith
I just took care of this same issue yesterday. The simplest solution was to alter my custom action DLL so that it took the string parameters I need to pass to it instead of taking an MSIHANDLE. The reason you need the MSIHANDLE is so that you can call MsiGetProperty() to get the CustomActionData string, right? Then you have to parse that string to get all of your individual values.
Just alter your DLL function so that it takes the values, themselves. For instance, I changed:
UINT __stdcall Install(MSIHANDLE hModule);
To:
UINT __stdcall Install(char myVal1[], char myVal[]);
Then, from my InstallAware MSICode, after calling "Apply Install," I put a "Call DLL Function" to call the Install() method within my custom action DLL, passing it a couple of "allocated string buffer" parameters.
Posted: Thu Nov 06, 2008 10:19 am
by allensm
so you actually passed your parms in and out of the custom action with a string? That seems like such a hack compared to what you are supposed to do in this situation. :/
Posted: Thu Nov 06, 2008 10:39 am
by jsmith
What you should do is concatenate all your params into a string then set the MSI property, "CustomActionData," to that string. That's what I wanted to do, as well. Unfortunately, I searched this forum for "MSIHANDLE" and only found a few results where the IA support folks couldn't or wouldn't answer how to get the MSIHANDLE to pass in to the DLL call. In the interest of moving forward in evaluating IA, I chose to pass the params in as strings.
Posted: Thu Nov 06, 2008 11:06 am
by allensm
how do you get the results out though?
Posted: Thu Nov 06, 2008 11:30 am
by jsmith
I don't care about the result from mine, but it looks like the "Call DLL Function" dialog has a "Return Type" dropdown and a "Return result in variable" text box.