Skip to content

Instantly share code, notes, and snippets.

@melice
Created May 14, 2012 09:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melice/2692928 to your computer and use it in GitHub Desktop.
Save melice/2692928 to your computer and use it in GitHub Desktop.
fileexist for win 64bit
function FileExists64(const FileName: string):Boolean;
type TWow64DisableWow64FsRedirection = function(var Wow64FsEnableRedirection: LongBool): LongBool; stdcall;
TWow64EnableWow64FsRedirection = function(Wow64FsEnableRedirection: LongBool): LongBool; stdcall;
var hHandle: THandle;
Wow64DisableWow64FsRedirection : TWow64DisableWow64FsRedirection;
Wow64EnableWow64FsRedirection : TWow64EnableWow64FsRedirection;
Wow64FsEnableRedirection : LongBool;
begin
hHandle := GetModuleHandle('kernel32.dll');
@Wow64EnableWow64FsRedirection := GetProcAddress(hHandle, 'Wow64EnableWow64FsRedirection');
@Wow64DisableWow64FsRedirection := GetProcAddress(hHandle, 'Wow64DisableWow64FsRedirection');
if (hHandle <> 0) and (@Wow64EnableWow64FsRedirection <> nil)
and (@Wow64DisableWow64FsRedirection <> nil) Then
begin
Wow64DisableWow64FsRedirection(Wow64FsEnableRedirection);
Result := FileExists(FileName);
Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection);
end
else Result:=False;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment