It seems, that some files which I wanna check with FileExists() can never be found even if they are there, others are found every time.
If I put the file "driver.sys" into the "C:\Windows\System32\drivers\" directory, it would never be found (FileExists is false every time i call the function). If I move the file into the Windows root "C:\Windows\" it is found.
This doesn't work (while the file is definitely in the folder 'C:\Windows\System32\drivers\'):
function isNotDriverInstalled(): Boolean;
begin
if (FileExists('C:\Windows\System32\drivers\driver.sys')) then begin
Log('File exists');
Result := False;
end else begin
Log('File doesn''t exist');
Result := True;
end;
end;
This works (while the file is in the folder 'C:\Windows\'):
function isNotDriverInstalled(): Boolean;
begin
if (FileExists('C:\Windows\driver.sys')) then begin
Log('File exists');
Result := False;
end else begin
Log('File doesn''t exist');
Result := True;
end;
end;
Btw: I am using Windows 7, 64 Bit.
Has anybody experienced such a case before? Any suggestions?
Thx in advance!
Your
System32
directory is mapped to theSysNative
path due toFile System Redirector
, so as you can see, hardcoding of such directory path is not that easy. Better use one of built-in constants listed below:1. The {sys} constant:
You can use the
{sys}
constant, but make sure you allowed the setup to run in 64-bit mode. For more information about how to do it, see theArchitecturesInstallIn64BitMode
directive reference and be sure to read the64-bit Installation Limitations
topic.From the
{sys}
constant reference:Here is how you can use it:
2. The {syswow64} constant:
From the
{syswow64}
constant reference:Here is how you can use it: