
[英]I get 'A 32 bit processes cannot access modules of a 64 bit process.' exception invoking Process.Start()
[英]A 32 bit processes cannot access modules of a 64 bit process using C#
我需要访问活动程序并调试活动程序的名称,但是当我使用获取进程 ID 时,我得到 32 位程序错误无法访问 64 位进程
static void Main(string[] args)
{
while (true)
{
IntPtr hWnd = GetForegroundWindow();
uint procId = 0;
GetWindowThreadProcessId(hWnd, out procId);
var proc = Process.GetProcessById((int)procId);
Debug.WriteLine(proc.MainModule);
//Console.ReadKey();
}
}
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", SetLastError = true)]
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
}
在 64 位 Windows 上,64 位进程无法加载 32 位动态链接库 (DLL)。 此外,32 位进程无法加载 64 位 DLL。 但是,64 位 Windows 支持 64 位和 32 位进程(在同一台计算机上和跨计算机)之间的远程过程调用 (RPC)。 在 64 位 Windows 上,进程外的 32 位 COM 服务器可以与 64 位客户端通信,进程外的 64 位 ZD47C174ED277BDF06CFC72763AB37 客户端可以通信因此,如果您有一个不支持 COM 的 32 位 DLL,您可以将其包装在进程外 COM 服务器中,并使用 COM 对进程的调用进行处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.