Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 4

Err.Description returns null

Hi Karthic here.

I am doing Install script MSI project, ofcourse it uses event driven install script code.
In OnBegin() event I am doing a registry read. If the registry read fails then the I am throwing an error message to the user as below

if (RegDBGetKeyValueEx("SOFTWARE\\MICROSOFT",svKey, nvType, svValue, nvNum) < 0) then
MessageBox(Err.Number + " - Number", INFORMATION);
MessageBox(Err.Description + "- Description", INFORMATION);
MessageBox(Err.Source + "- Source", INFORMATION);
MessageBox(Err.HelpFile + "- HelpFile", INFORMATION);
MessageBox(Err.HelpContext + "- HelpContext", INFORMATION);
MessageBox(Err.LastDllError + "- LastDllError", INFORMATION);

->Please note that on purpose i am reading a key which is not present and the RegDBSetDefaultRoot is not used.

No message box has a valid information about the occured error.
Can anyone provide any information on this

Thanks in advance

further on surfing i got info that try catch need to be used to do with Err object. In install script is it such a way that Err object is used only with try catch?
any error occured outside try catch assue a registry read is done which fails will update the Err number.
Do i Need to #include or set some option in the rul file to use it?
Please put forward your views... i dont understand how it works!!
Labels (1)
0 Kudos
(1) Reply
Level 10 Flexeran
Level 10 Flexeran

Most of the fields in the Err object are only populated when an exception occurs during execution of the setup script. Typically this would occur when attempting to call a method or property on a COM object threw an exception, in which case the fields in the Err object are populated with the COM exception information. When using a try/catch block to catch any exceptions, the Err object will be populated with as much information that is available regarding the exception.

The LastDllError field is populated whenever an external DLL function call is made, such as to a Win32 API in kernel32.dll. This provides the last Win32 error typically obtained through GetLastError in a Windows application.

If you are trying to obtain a text description of an error returned by an InstallScript function, you can pass the error code to the InstallScript FormatMessage function, which will return a string with the error description if one is available.
0 Kudos