LowLevelKeyboardProc The LowLevelKeyboardProc hook procedure is an application-defined or library-defined callback function used with the SetWindowsHookEx function. The system calls this function every time a new keyboard input event is about to be posted into a thread input queue. The keyboard input can come from the local keyboard driver or from calls to thekeybd_event function. If the input comes from a call to keybd_event, the input was "injected". The HOOKPROC type defines a pointer to this callback function. LowLevelKeyboardProc is a placeholder for the application-defined or library-defined function name. LRESULT CALLBACK LowLevelKeyboardProc( int nCode, // hook code WPARAM wParam, // message identifier LPARAM lParam // pointer to structure with message data );用这个应该就可以了。不过win9x不支持
{
if (wParam == VK_F2)
{
wParam = VK_SPACE;
} return CallNextHookEx(g_msg,nCode,wParam,lParam);
}上面这段代码是试图让用户按下F2之后实际是按下的空格键~~我在debug的时候,发现wParam值已经被修改了,但是依然没有作用~
if (wParam == VK_F2)
{
wParam = VK_SPACE;
}
wParam是个在stack里面的参数,是一份传进来的参数的拷贝,这里所做的修改只改了stack里面的值,这个修改没办法传出到系统,一退出这个函数就无效了。
if (wParam == VK_F2)
{
wParam = VK_SPACE;
}
wParam是个在stack里面的参数,是一份传进来的参数的拷贝,这里所做的修改只改了stack里面的值,这个修改没办法传出到系统,一退出这个函数就无效了。
不过这个市在函数结束前作为参数传给CallNextHookEx了。应该是有效的
The LowLevelKeyboardProc hook procedure is an application-defined or library-defined callback function used with the SetWindowsHookEx function. The system calls this function every time a new keyboard input event is about to be posted into a thread input queue. The keyboard input can come from the local keyboard driver or from calls to thekeybd_event function. If the input comes from a call to keybd_event, the input was "injected". The HOOKPROC type defines a pointer to this callback function. LowLevelKeyboardProc is a placeholder for the application-defined or library-defined function name. LRESULT CALLBACK LowLevelKeyboardProc(
int nCode, // hook code
WPARAM wParam, // message identifier
LPARAM lParam // pointer to structure with message data
);用这个应该就可以了。不过win9x不支持