源码下载:http://download.csdn.net/detail/sunylat/9740352
unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } function DisableWowRedirection: Boolean; function RevertWowRedirection: Boolean; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses System.IOUtils; procedure TForm1.Button1Click(Sender: TObject); const sourceFile = 'c:windowssystem32cdedit.exe'; var destFile: string; begin destFile := ExtractFilePath(paramstr(0)) + 'bcdedit.exe'; try self.DisableWowRedirection; try if TFile.Exists(sourceFile) = true then begin self.Caption := '存在'; TFile.Copy(sourceFile, destFile); end else begin self.Caption := '不存在'; end; except on e: exception do begin showmessage(e.ToString); end; end; finally self.RevertWowRedirection; end; end; function TForm1.DisableWowRedirection: Boolean; type TWow64DisableWow64FsRedirection = function(var Wow64FsEnableRedirection : LongBool): LongBool; StdCall; var hHandle: THandle; Wow64DisableWow64FsRedirection: TWow64DisableWow64FsRedirection; isRedirect:LongBool; begin isRedirect := true; try hHandle := GetModuleHandle('kernel32.dll'); @Wow64DisableWow64FsRedirection := GetProcAddress(hHandle, 'Wow64DisableWow64FsRedirection'); if ((hHandle <> 0) and (@Wow64DisableWow64FsRedirection <> nil)) then Wow64DisableWow64FsRedirection(isRedirect); except isRedirect := False; end; result:=isRedirect; end; function TForm1.RevertWowRedirection: Boolean; type TWow64RevertWow64FsRedirection = function(var Wow64RevertWow64FsRedirection : LongBool): LongBool; StdCall; var hHandle: THandle; Wow64RevertWow64FsRedirection: TWow64RevertWow64FsRedirection; isRedirect:LongBool; begin isRedirect := true; try hHandle := GetModuleHandle('kernel32.dll'); @Wow64RevertWow64FsRedirection := GetProcAddress(hHandle, 'Wow64RevertWow64FsRedirection'); if ((hHandle <> 0) and (@Wow64RevertWow64FsRedirection <> nil)) then Wow64RevertWow64FsRedirection(isRedirect); except isRedirect := False; end; result:=isRedirect; end; end.