Win32 C ++可以通过过程发送额外的信息 [英] Win32 C++ Can Extra Info be Sent with a Procedure

查看:56
本文介绍了Win32 C ++可以通过过程发送额外的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试避免将任何窗口句柄存储为全局窗口.到目前为止,我还不错.

I have been trying to avoid storing any window handles as a global. Up to this point I have been fine.

我现在正在使用键盘挂钩程序,并且试图找到一种将主Windows句柄传递给它的方法.

I am using a keyboard hook procedure now, and I am trying to find, if there is a way, to pass my main windows handle to it.

如果真的不能以简单的方式完成操作,我可以将主窗口句柄设置为全局.

If it can't really be done in a simple way, I can just make the main window handle global.

LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam);

有没有一种方法可以将句柄包含在其中一个参数中?

Is there a way I can include the handle within one of the parameters?

谢谢.

推荐答案

不,没有.挂钩参数是固定的,并且它们都由OS使用.您必须全局存储句柄.而且,如果要在挂接多个进程的DLL中实现挂接过程,则需要将该全局存储在共享内存中,以便DLL的每个实例都可以到达它.

No, there is not. The hook parameters are fixed, and all of them are used by the OS. You must store your handle globally. And if you are implementing the hook procedure in a DLL that is hooking multiple processes, you need to store that global in shared memory so every instance of the DLL can reach it.

这篇关于Win32 C ++可以通过过程发送额外的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆