本文介绍了如何在 win64 上禁用重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 c:Windowsegedit.exe 复制到与 regedit2.exe 名称相同的目录但是当我尝试复制它时,我出错了说 regedit.exe 文件未找到"或有时将其复制到 windowsSysWOW64 目录下.实际上我知道 win64 正在重定向它 但是如何我可以禁用重定向并将 windows/regedit.exe 复制到 windows/regedit2.exe.我的示例代码是

I want to copy c:Windowsegedit.exe to same directory with regedit2.exe name But when I try to copy it,I take an error which say regedit.exe file not found" or sometimes copy it to under windowsSysWOW64 directory. And actually I knıow win64 is redirecting it But how can I disable redirecting and copy windows/regedit.exe to windows/regedit2.exe. My sample code is

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

有谁能帮帮我

推荐答案

有可用的 Win32 函数可以禁用和启用重定向.

There are Win32 functions available that can disable and enable redirection.

[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);

这篇关于如何在 win64 上禁用重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 06:18