Inno Setup GetExceptionMessage returns an empty message

in the Inno Setup script, GetExceptionMessage returns an empty message (it contains only the colon ":" character). The latest version of Inno Setup (5.4.2) is used.

try
  Log('Create IISNamespace');
  // Create IIS namespace object
  if Length(virtualDirectoryName) > 0 then
  begin
    IIS := CreateOleObject('IISNamespace');
    Log('Get IIsWebService');
    WebSite := IIS.GetObject('IIsWebService', IISServerName + '/w3svc');
    Log('Get IIsWebServer');
    WebServer := WebSite.GetObject('IIsWebServer', IISServerNumber);
    Log('Get IIsWebVirtualDir');
    WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root');
    Log('Delete IIsWebVirtualDir');
    WebRoot.Delete('IIsWebVirtualDir', virtualDirectoryName);
    WebRoot.SetInfo();
  end;
except
  MsgBox(ExpandConstant('{cm:IISException,'+ GetExceptionMessage +'}'),
    mbInformation, mb_Ok);
  Log('Uninstall IIS 6 exception: ' + GetExceptionMessage);
end;

An exception occurs when you delete IIsWebVirtualDir. Is there a way to get the type of exception or a real exception message?

Thanks, Denis.

+3
source share
1 answer

I just wrote the following example to see if GetExceptionMessageor is broken ShowExceptionMessage. I used the settings of Inno 5.4.2 Unicode and Ansi.

[Setup]
AppName=Test
AppVersion=1.5
DefaultDirName={pf}\test

[Code]
function InitializeSetup(): Boolean;
var
 I: Integer;
begin
 try
  I := I div 0; // Raise an exception 
 except
      MsgBox(GetExceptionMessage,
      mbError, MB_OK);

      ShowExceptionMessage;
 end;
 result := false;
end;

CodeAutomation.iss, , , . , ., .

, , , Script , , ISSNamespace, .

[Setup]
AppName=Test
AppVersion=1.5
DefaultDirName={pf}\test
[CustomMessages]
IISException =ISS Exception " %1 " occured.

[Code]

const
  IISServerName = 'localhost';
  IISServerNumber = '1';
  IISURL = 'http://127.0.0.1';

function InitializeSetup(): Boolean;
var
  IIS, WebSite, WebServer, WebRoot, VDir: Variant;
  virtualDirectoryName : String;
begin
virtualDirectoryName := 'test';
try
  Log('Create IISNamespace');
  // Create IIS namespace object
  if Length(virtualDirectoryName) > 0 then
  begin
    IIS := CreateOleObject('IISNamespace');
    Log('Get IIsWebService');
    WebSite := IIS.GetObject('IIsWebService', IISServerName + '/w3svc');
    Log('Get IIsWebServer');
    WebServer := WebSite.GetObject('IIsWebServer', IISServerNumber);
    Log('Get IIsWebVirtualDir');
    WebRoot := WebServer.GetObject('IIsWebVirtualDir', 'Root');
    Log('Delete IIsWebVirtualDir');
    WebRoot.Delete('IIsWebVirtualDir', virtualDirectoryName);
    WebRoot.SetInfo();
  end;
except
 MsgBox(ExpandConstant('{cm:IISException,'+ GetExceptionMessage +'}'),
    mbInformation, mb_Ok);
  Log('Uninstall IIS 6 exception: ' + GetExceptionMessage);
end;
end;

Script, .

[CustomMesssages], , % 1. .

0

All Articles