msi handle to c++ custom action

Got a problem you cannot solve? Try here.
Post Reply
allensm
Posts: 7
Joined: Mon Oct 13, 2008 3:05 pm

msi handle to c++ custom action

Post 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.
jsmith
Posts: 178
Joined: Tue Nov 04, 2008 10:47 am

Post 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.
allensm
Posts: 7
Joined: Mon Oct 13, 2008 3:05 pm

Post 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. :/
jsmith
Posts: 178
Joined: Tue Nov 04, 2008 10:47 am

Post 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.
allensm
Posts: 7
Joined: Mon Oct 13, 2008 3:05 pm

Post by allensm »

how do you get the results out though?
jsmith
Posts: 178
Joined: Tue Nov 04, 2008 10:47 am

Post 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.
Post Reply