是否可以在Qt应用程序中使用Win32 Hooks [英] Is it possible to use Win32 Hooks in Qt applications
问题描述
我想知道它是否可能在Qt应用程序中使用win32键盘挂钩函数(SetWindowsHookEx,SetWindowsHookEx)。
I like to know if its possible to use win32 keyboard hook function (SetWindowsHookEx , SetWindowsHookEx ) in a Qt application.
如果可能,请在Qt中提供使用SetWindowsHookEx,SetWindowsHookEx函数的示例代码。
If possible pls provide a sample code on using SetWindowsHookEx , SetWindowsHookEx functions in Qt.
of 2010年2月18日//
//Update as of 18 Feb 2010 //
我无法想象如何在QT中做到这一点。
I havent figured out how to do that in QT yet.
一个解决方法我使用vc ++ express版本创建了一个win32 dll,并将我的hook命令放在dll函数中。
我使用QLibrary类来从Qt调用dll函数
But as a workaround I have created a win32 dll using vc++ express edition and placed my hook commands inside the dll functions. And I call that dll functions from Qt using QLibrary class
/* hearder file code*/
QLibrary *myLib;
typedef HHOOK (*MyPrototype)(HINSTANCE);
/* source file code */
myLib = new QLibrary( "ekhook.dll" );
MyPrototype myFunction;
myFunction = (MyPrototype) myLib->resolve( "Init" );
$ b
init()是ekhook.dll中被调用的函数
init() is the function in ekhook.dll thats being called
推荐答案
您不需要对Qt做任何事情。只需按照下面的示例:
You don't need to do anything with Qt. Just follow the windows examples:
http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
这篇关于是否可以在Qt应用程序中使用Win32 Hooks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!