function ChangeFSRedirection(bDisable: BOOL): BOOL;
type
TWow64DisableWow64FsRedirection =
function(
var Wow64FsEnableRedirection: BOOL): BOOL;
stdcall;
TWow64EnableWow64FsRedirection =
function(
var Wow64FsEnableRedirection: BOOL): BOOL;
stdcall;
function Is64Bit: Boolean;
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE;
Result := Reg.KeyExists('
\SOFTWARE\Wow6432Node');
Reg.Free;
end;
var
Handle: THandle;
Wow64DisableWow64FsRedirection: TWow64DisableWow64FsRedirection;
Wow64EnableWow64FsRedirection: TWow64EnableWow64FsRedirection;
Wow64FsEnableRedirection: BOOL;
begin
Result := true;
if not Is64Bit
then
exit;
try
Handle := GetModuleHandle('
kernel32.dll');
@Wow64EnableWow64FsRedirection := GetProcAddress(
Handle, '
Wow64EnableWow64FsRedirection');
@Wow64DisableWow64FsRedirection := GetProcAddress(
Handle, '
Wow64DisableWow64FsRedirection');
if ((
Handle <> 0)
and (@Wow64EnableWow64FsRedirection <>
nil)
and
(@Wow64DisableWow64FsRedirection <>
nil))
then
if bDisable
then
Wow64DisableWow64FsRedirection(Wow64FsEnableRedirection)
else
Wow64EnableWow64FsRedirection(Wow64FsEnableRedirection);
except
Result := false;
end;
end;