C# 在 64 位系统上调用 user32.dll
从 64 位应用程序在 64 位 Windows 上 pinvoke user32.dll 是否错误?我已经成功地完成了很多次并且从未出现过错误,但这似乎是矛盾的。我应该寻找 user64.dll 吗?
Is it wrong to pinvoke user32.dll on 64 bit Windows, from a 64 bit app? I've done this successfully a number of times and never had an error, but it seems contradictory. Should I look for user64.dll instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
user32.dll
这个名称具有误导性。这是您正在调用的user32.dll
的 64 位版本。 64 位版本位于%windir%\System32\user32.dll
。包含 32 位版本以与 32 位应用程序兼容。它位于
%windir%\SysWOW64\user32.dll
。您可以使用 dumpbin 实用程序检查它们:System32\user32.dll:
SysWOW64\user32.dll:
The name
user32.dll
is misleading. It's the 64 bit version ofuser32.dll
you're calling. The 64 bit version is located at%windir%\System32\user32.dll
.A 32-bit version is included for compatibility with 32-bit applications. It's located at
%windir%\SysWOW64\user32.dll
. You can inspect them using thedumpbin
utility:System32\user32.dll:
SysWOW64\user32.dll:
没有 user64.dll 的原因与您刚才描述的完全相同,.NET 程序可能与 CPU 架构无关,因此相同的代码需要在 x86 和 x64 上工作。
如果您将程序移植到 x86 平台,它仍然可以运行,无需任何修改。
我猜想当他们命名 user32.dll 时,他们并没有考虑到这些场景。
There is no user64.dll for the exact same reason you just described, .NET program can be agnostic to CPU architecture so the same code needs to work on x86 and x64.
If you take your program to x86 platform, it will still run without any modifications.
I guess that when they named user32.dll, they didn't have those scenarios in mind.