还是要用钩子,program大概如下。
#include
HHOOK OldHook=NULL;
HINSTANCE hInst=NULL;
int WINAPI DllEntryPoint(HINSTANCE hinst, DWORD dwReason, void*)
{
if (dwReason==DLL_PROCESS_ATTACH)
hInst = hinst;
else if(dwReason==DLL_PROCESS_DETACH)
if (OldHook)
UnhookWindowsHookEx(OldHook);
return 1;
}
long CALLBACK KeyProc(int code, WPARAM wParam, LPARAM lParam)
{
return 1; //锁定任何按键。
}
BOOL _export CALLBACK DisableKB(bool disable)
{
if (disable) {
if (OldHook == NULL)
OldHook = SetWindowsHookEx(WH_KEYBOARD_LL,
(HOOKPROC)KeyProc, hInst, NULL);
return OldHook != NULL;
}
else {
if (OldHook && UnhookWindowsHookEx(OldHook))
OldHook = NULL;
return OldHook == NULL;
}
}
是控制你自己的程序键盘不能用还是全局,全局肯定要钩子,如果是你自己程序那你重写winproc 函数
一楼的那个人太坏了,那个东西是病毒。。。。。