Windows CE下的键盘钩子

 2 E币 
成为会员,免费下载资料
文件大小:2.21 KB 上传者: 时间:2008-08-18 22:21:13 下载量:9
在coredll.dll中有SetWindowsHookEX相关函数,这里用LoadLibrary和GetProcAddress可以调用。
以下是测试代码:
[hide]//Install the KB hook by passing the
//handle of the application to be hooked
//and the address of the KB procedure
//which will handle all the KB events
if(!ActivateKBHook(hInstance, LLKeyboardHookCallbackFunction))
{
    MessageBox(GetActiveWindow(),
        TEXT("Couldn't intall hook...Terminating"),
        TEXT("Warning"), NULL);
    exit(1);
}

//LLKeyboardHookCallbackFunction is the funtion whose
//address we passed to the system while installing the hook.
//so all the KB events will bring the control to this procedure.
//Here we want that when the user presse left or
//right key it should be interpreted as an UP key
//so now you can allow the user to configure the
//key boards the way he/she wants it
LRESULT CALLBACK LLKeyboardHookCallbackFunction(
                  int nCode, WPARAM wParam, LPARAM lParam)
{
    if(((((KBDLLHOOKSTRUCT*)lParam)->vkCode) == VK_LEFT) ||
           ((((KBDLLHOOKSTRUCT*)lParam)->vkCode) == VK_RIGHT))
    {
        //Generate the keyboard press event of the mapped key
        keybd_event(VK_UP, 0, 0, 0);

        //release the mapped key
        keybd_event(VK_UP, 0, KEYEVENTF_KEYUP, 0);
    }

    //let default processing take place
    return CallNextHookEx(g_hInstalledLLKBDhook, nCode,
                                              wParam, lParam);
}

//we are done with the hook. now uninstall it.
DeactivateKBHook();
Windows CE下的键盘钩子程序的应用这里有个例程...[/hide]

[ 本帖最后由 crystal 于 2008-8-18 22:22 编辑 ]
展开
折叠
678
评论
共 0 个
内容存在敏感词
    易百纳技术社区暂无数据
相关资料
关于作者
易百纳技术社区
贡献资料 21
易百纳技术社区 我上传的资料
登录查看
我赚取的积分
登录查看
我赚取的收益
登录查看
上传资料 赚取积分兑换E币
易百纳技术社区
删除原因
广告/SPAM
恶意灌水
违规内容
文不对题
重复发帖
置顶时间设置
结束时间
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-资料模块

审核失败

失败原因
备注
易百纳技术社区