MSIHANDLE argument to custom dll functions

Got a problem you cannot solve? Try here.
Brian THOMAS
Posts: 2
Joined: Wed Jan 16, 2013 11:54 am
Location: Oxford, UK
Contact:

MSIHANDLE argument to custom dll functions

Postby Brian THOMAS » Wed Jan 16, 2013 12:10 pm

Background
I'm trying out the 30 day evaluation of IA 15. Currently we use MakeMSI to build MSIs. Considering moving to WiX or IA.

Problem
I already have a working dll containing a function with this prototype:

Code: Select all

UINT __stdcall InstallPrinterDriver (MSIHANDLE hInstall)
As msiexec installs my msi, my dll gets loaded, the dll entry point gets called and the function implementation passes the hInstall argument to MsiRecordSetString so the dll can write its progress and error messages to the logfile generated via the msiexec /l*v switch.

I'd prefer not to have to modify my dll source code. How can I get IA to give me an MSIHANDLE argument when it calls my function?
Or if it can't give me an MSIHANDLE, how can I get my log messages to appear in the log file?

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: MSIHANDLE argument to custom dll functions

Postby FrancescoT » Thu Jan 17, 2013 10:34 am

Dear Brian,

With InstallAware you can call any NATIVE dll within a script without limitation but you can't pass a pointer to the MSI handle using the Call DLL command.
In your case, you should modify your DLL function prototype in order to accept directly the parameters that your code requires.

The Call DLL command accepts any kind of parameter and script variables value as well.

Regarding your question about customized log information, you may add custom diagnostic information to the setup log anywhere in your MSIcode script by calling Write to Text File on the pre-defined variable $LOGGED$.

Hope this helps you.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

Brian THOMAS
Posts: 2
Joined: Wed Jan 16, 2013 11:54 am
Location: Oxford, UK
Contact:

Re: MSIHANDLE argument to custom dll functions

Postby Brian THOMAS » Thu Jan 17, 2013 11:11 am

Thank you for the reply.
I see that it's very straightforward to write messages from within MSIcode.
But - I posted the original question because I wanted to know how from within my custom dll can I write log messages?
My dll currently calls MsiRecordSetString to log each message, but that function requires an MSIHANDLE argument.
If IA doesn't give my dll an MSIHANDLE, how can my dll log messages?

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: MSIHANDLE argument to custom dll functions

Postby FrancescoT » Thu Jan 17, 2013 11:52 am

Dear Brian,

In this case you can't ... but you could return a string pointer from your DLL which contains the log information you want to add.
Then when your code completes, write the string buffer from the IA script.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 107 guests