在各个uadu

在各个uadu

10个粉丝

118

问答

1240

专栏

10

资料

在各个uadu  发布于  2008-08-18 22:21:13
采纳率 1%
118个问答
3485

Windows CE下的键盘钩子

 
在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 编辑 ]
易百纳技术社区文件: WinCEKBHook_src.zip
下载
我来回答
回答0个
时间排序
认可量排序
易百纳技术社区暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

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

详细说明

易百纳技术社区