msi handle to c++ custom action
msi handle to c++ custom action
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.
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.
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.
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.

