1
votes

I have a sys file in the System32\Drivers folder called gpiotom.sys (custom sys file). My my application is strictly 32-bit compatible only, so my installer runs in 32-bit mode. My script needs to find if this sys file exists or not.

I used the FileExists function explained on the below post but it does not work since it only works for 64-bit application only:

InnoSetup (Pascal): FileExists() doesn't find every file

Is there any way I can find if my sys file exists or not in a 32-bit mode?

Here is my code snippet in Pascal Script language:

function Is_Present() : Boolean;
begin
  Result := False;
  if FileExists('{sys}\driver\gpiotom.sys') then
  begin
    Log('File exists');
    Result := True;
  end;
end;
1
What does "doesn't work" mean? What have you tried? What's the log from a failing install? Do you have a minimal, complete, verifiable example?mirtheil
What "sys file" exactly? 32-bit or 64- bit file? + "64 bit mode of application" - what application? - Is this really XP-specific question? Don't you really have the same problem on later versions of Windows?Martin Prikryl
Hello, There is a custom gpio sys which is present in this folder called gpiotom.sys which i have to find in my installer. I have tried the options mentioned in the above post. But it is able to find the sys file only in 64 bit mode of application but my application is strictly in 32 bit mode. FileExists() function does not work for detecting sys files in 32 bit application. is there any other way to find them ?harish sai
Why don’t you update your question and provide the log.Andrew Truckle

1 Answers

1
votes

In general, I do not think there is any problem running an installer for 32-bit application in 64-bit mode. Just make sure you use 32-bit paths where necessary, like:

[Setup]
DefaultDirName={pf32}\My Program

Anyway, if you want to stick with 32-bit mode, you can use EnableFsRedirection function to disable WOW64 file system redirection.

With use of this function, you can implement a replacement for FileExists:

function System32FileExists(FileName: string): Boolean;
var
  OldState: Boolean;
begin
  if IsWin64 then
  begin
    Log('64-bit system');
    OldState := EnableFsRedirection(False);
    if OldState then Log('Disabled WOW64 file system redirection');
    try
      Result := FileExists(FileName);
    finally
      EnableFsRedirection(OldState);
      if OldState then Log('Resumed WOW64 file system redirection');
    end;
  end
    else
  begin
    Log('32-bit system');
    Result := FileExists(FileName);
  end;

  if Result then
    Log(Format('File %s exists', [FileName]))
  else
    Log(Format('File %s does not exists', [FileName]));
end;