Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

MsiGetLastErrorRecord


2 replies to this topic

Matthias1967

Matthias1967
  • Full Members
  • 92 posts

Posted 06 August 2009 - 07:51

Hello,

For each install on a target machine, I want to add a *short* summary to an "external" log file.

For this purpose, I have written some custom actions that log the start, the successful installation, user interrupt, and abort.

For an abort, I want to include at least the relevant error number (or better some error text - Error table?) in the logfile. So I wrote (in InstallScript):

CODE

nvBufferSize=1024;
ErrRec=MsiGetLastErrorRecord();
MsiFormatRecord(hMSI,ErrRec,svErrMsg,nvBufferSize);
svOutStr= "Installation of MyProduct aborted, error: "+svErrMsg;


However, the svErrMsg remains empty.

I run this custom action by a control event published by the Finish button on the SetupCompleteError dialog and (for silent installations) I have scheduled it with number -3 in the InstallExecuteSequence.

Maybe I should have run MsiGetLastErrorRecord at a different place, but I do not know where to put it. As far as I see, there is nothing like an "OnError" event handler, is there?

Best regards

Matthias

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 06 August 2009 - 12:27

MsiGetLastErrorRecord returns a record with information about the last failed API call. For instance, when you call MsiSetFeatureState for a non-existing feature, it returns an error code. To get more information about the error, you can call MsiGetLastErrorRecord.

This is different from the reason why the installation is failing. Say you have a setup with a launch condition. You install on a computer, and that condition is not met, so the installation fails. But the launch conditions were processed correctly, therefore MsiGetLastErrorRecord is empty.

Matthias1967

Matthias1967
  • Full Members
  • 92 posts

Posted 06 August 2009 - 13:08

Thank you, I am starting to understand it. So my issue moves a bit: is there a "safe" way to extract the reason why the installatoin is failing? As of now, I do not see one.