2

Code was working normally, but after upgrading to inno 6.0.2, i got an error when compile. Error:

Type mismatch

in line if LoadStringFromFile(TmpFile, ExecStdout) then code as below:

function NextButtonClick(CurPageID: Integer): Boolean;
var
  TmpFile, ExecStdout: string;
  ResultCode: integer;
begin
  Result := True;
  if CurPageID = HostingPage.ID then
    begin
      Domain   := HostingPage.values[0];
      DomainPort := HostingPage.values[1];

        TmpFile := ExpandConstant('{tmp}') + '\~pid.txt';
        Exec('cmd.exe',
        '/C FOR /F "usebackq tokens=5 delims= " %i IN (`netstat -ano ^|find "0.0:'+DomainPort+'"`) DO '
        + '@tasklist /fi "pid eq %i" | find "%i" > "' + TmpFile + '"', '', SW_HIDE,
        ewWaitUntilTerminated, ResultCode);
        if LoadStringFromFile(TmpFile, ExecStdout) then
        begin
            MsgBox('The Port ('+DomainPort+')  ' #13 + ExecStdout, mbError, MB_OK);
            Result := False;
        end;
        DeleteFile(TmpFile);
    end;    
end;
M.A_55
  • 135
  • 17

1 Answers1

4

The code you posted in not complete, always post MCVE.

The problem resides in using wrong type of parameter, see the documentation:

function LoadStringFromFile(const FileName: String; var S: AnsiString): Boolean;

Change it like this:

function NextButtonClick(CurPageID: Integer): Boolean;
var
  TmpFile: String;
  ExecStdout: AnsiString; // << Was String in your script
  ResultCode: Integer;

This is because Inno Setup 6 is Unicode only:

Change in default behavior: Starting with Inno Setup 6 there's only one version available: Unicode Inno Setup. Unicode Inno Setup has been available for 9 years but in case you have not yet updated to it: please see the Unicode Inno Setup topic in the help file for more information. Basically, unless you're using [Code] to make DLL calls with string parameters you shouldn't have to make any changes to your script.

Slappy
  • 5,250
  • 1
  • 23
  • 29