如果我使用 C#,如何找出 WM_MOUSEMOVE 和 WM_MOUSEDOWN 等 Windows 常量是什么?

发布于 2024-08-28 22:53:13 字数 255 浏览 5 评论 0原文

我正在编写一些代码,这些代码使用一些对 user32 函数的非托管调用,例如 SetWindowsHookEx 等。

这需要我使用大量我不确定它们的值是什么的常量。例如,如果我想将钩子设置为低级鼠标钩子,我需要知道 WM_MOUSE_LL = 14。

在哪里可以查找这些?

我需要知道 WM_MOUSEMOVE、WM_MOUSEDOWN 等是什么。当我处理互操作代码时,找到这些代码的最简单方法是什么?我是否可以将它们导入到 C# 中以便定义它们?

I'm writing some code that uses some unmanaged calls into user32 functions such as SetWindowsHookEx, etc.

This requires me to use lots of constants that I'm not sure what their value is. For example, if I want to set the hook as a low-level mouse hook I need to know that WM_MOUSE_LL = 14.

Where can I look these up?

I need to know what WM_MOUSEMOVE, WM_MOUSEDOWN, and more are. When I'm dealing with interop code, what is the easiest way for me to find these? Is it possible for me to import them into C# so they will be defined?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

×纯※雪 2024-09-04 22:53:13

它在你的机器上。如果您有 VS2008,则打开 c:\program files\microsoft skds\windows\v6.0a\winuser.h 并搜索消息标识符。不,您不能在 C# 程序中使用此文件,它是用 C 编写的。

有一个工具可以将这些 SDK 头文件转换为 C#,请下载 P/调用互操作助手。单击“SigImp 搜索”选项卡并输入您要查找的标识符。单击“生成”以创建 C# 声明。对于消息标识符来说还好,但是对于 API 函数来说就很难看了。这些声明是自动翻译的,并且非常嘈杂,而且并不总是最佳的。使用 pinvoke.net 上提供的内容仔细检查生成的定义

It's on your machine. If you've got VS2008 then open c:\program files\microsoft skds\windows\v6.0a\winuser.h and search for the message identifier. No, you can't use this file in a C# program, it is written in C.

There's a tool available that translated these SDK header files to C#, download the P/Invoke Interop Assistant. Click the "SigImp Search" tab and type the identifier you are looking for. Click Generate to create the C# declaration. Its okay for message identifiers but gets ugly for API functions. The declarations are auto-translated and are pretty noisy and not always optimal. Double-check the generated definition with what's available at pinvoke.net

香橙ぽ 2024-09-04 22:53:13

您了解 PInvoke.net 吗?

Do you know about PInvoke.net?

段念尘 2024-09-04 22:53:13

有时 MSDN 页面会列出它们,但我发现最好的方法是打开一个 C++ 程序并右键单击常量并说转到定义。

另一种即时查找几乎所有内容的方法是使用 Google 代码搜索。很多时候您会在 WINE 头文件中找到答案。

Sometimes the MSDN pages will list them, but I find the best way is to have a C++ program open and to right click on the constant and say go to definition.

Another way to instantly find out for almost anything is to use Google code search. Many times you'll find the answer in WINE header files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文