如何在win64上禁用重定向

我想使用regedit2.exe名称将c:\Windows\regedit.exe复制到同一目录但是当我尝试复制它时,我会收到一条错误,说明找不到regedit.exe文件“或有时将其复制到windows\SysWOW64目前。实际上我知道win64是重定向它但是如何禁用重定向并将windows / regedit.exe复制到windows / regedit2.exe。我的示例代码是

 if(File.Exists(@"c:\Windows\regedit.exe")) try { File.Copy(@"c:\Windows\regedit.exe", @"c:\Windows\regedit2.exe", true); } catch (Exception ex){} 

有任何人可以帮助我

有可用的Win32function可以禁用和启用重定向。

 [DllImport("kernel32.dll", SetLastError = true)] static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); [DllImport("kernel32.dll", SetLastError = true)] static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr); 

例:

 IntPtr wow64Value = IntPtr.Zero; // Disable redirection. Wow64DisableWow64FsRedirection(ref wow64Value); // Do whatever you need // ..................... // Re-enable redirection. Wow64RevertWow64FsRedirection(wow64Value);