获取按键的问题
下面代码是获取按键勾的DLL代码:
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma argsused
HHOOK hOldHook=0;
HWND hProcWnd=0;
HANDLE hInstance=0;
extern "C " __declspec(dllexport) void _stdcall SetHotKey(HWND hWnd);
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
hInstance=hinst;
return 1;
}
//-------------------------------------
LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
{
WPARAM wP=wParam;
if(nCode> =0)
{
AnsiString msg= " ";
if(wP> = 'A ' && wP <= 'D ')
msg= "press key:between a and d ";
else if(wParam==91) //91:left start menu
msg= "press key:left start memu ";
if(msg!= " ")
{//已实现:当按下A-D,左菜单键时:弹出一个对话框,可如何屏蔽这些键压下引起的其它事件呢?也就是当作没压下键一样。
//wP=0X00000000;//不起作用
MessageBox(NULL,msg.c_str(), "keyboard ",MB_OK);
}
}
return CallNextHookEx(hOldHook,nCode,wP,lParam);
}
//---------
void _stdcall SetHotKey(HWND hWnd)
{
hProcWnd=hWnd;
hOldHook=SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardProc,hInstance,0);
}
[解决办法]
C++ Builder BCB茶馆啊~~~~~~!