VC 的 UnHookWindowsHookEx函数问题?
我在MFC用的时候提示UnHookWindowsHookEx函数未定义。错误提示:'UnHookWindowsHookEx':undeclaredidentifier请问...
我在MFC用的时候提示UnHookWindowsHookEx函数未定义。错误提示:'UnHookWindowsHookEx' : undeclared identifier请问它被包含在哪个头文件中?谢谢~~~
展开
展开全部
头文件是winuser.h
看一下msdn:
UnhookWindowsHookEx
The UnhookWindowsHookEx function removes a hook procedure installed in a hook chain by the SetWindowsHookEx function.
BOOL UnhookWindowsHookEx(
HHOOK hhk // handle to hook procedure to remove
);
Parameters
hhk
Handle to the hook to be removed. This parameter is a hook handle obtained by a previous call to SetWindowsHookEx.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The hook procedure can be in the state of being called by another thread even after UnhookWindowsHookEx returns. If the hook procedure is not being called concurrently, the hook procedure is removed immediately before UnhookWindowsHookEx returns.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
看一下msdn:
UnhookWindowsHookEx
The UnhookWindowsHookEx function removes a hook procedure installed in a hook chain by the SetWindowsHookEx function.
BOOL UnhookWindowsHookEx(
HHOOK hhk // handle to hook procedure to remove
);
Parameters
hhk
Handle to the hook to be removed. This parameter is a hook handle obtained by a previous call to SetWindowsHookEx.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The hook procedure can be in the state of being called by another thread even after UnhookWindowsHookEx returns. If the hook procedure is not being called concurrently, the hook procedure is removed immediately before UnhookWindowsHookEx returns.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我曾经做的是在线程内实现的,没做成DLL方式,实现如下:
定义一个CCHook类,有2个成员函数:
BOOL WINAPI InstallHook();
BOOL WINAPI DeleteHook();
BOOL WINAPI CCHook::InstallHook()
{
gHook=SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,gInstance,GetCurrentThreadId());
if (gHook==NULL) return TRUE;
else return FALSE;
}
BOOL WINAPI CCHook::DeleteHook()
{
return UnhookWindowsHookEx(gHook);
}
定义全局函数:
LRESULT CALLBACK KeyboardProc(int code,WPARAM wparam,LPARAM lparam)
{
if (code<0)
{
return CallNextHookEx(gHook,code,wparam,lparam);
}
//处理代码
return CallNextHookEx(gHook,code,wparam,lparam);
}
定义一个CCHook类,有2个成员函数:
BOOL WINAPI InstallHook();
BOOL WINAPI DeleteHook();
BOOL WINAPI CCHook::InstallHook()
{
gHook=SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,gInstance,GetCurrentThreadId());
if (gHook==NULL) return TRUE;
else return FALSE;
}
BOOL WINAPI CCHook::DeleteHook()
{
return UnhookWindowsHookEx(gHook);
}
定义全局函数:
LRESULT CALLBACK KeyboardProc(int code,WPARAM wparam,LPARAM lparam)
{
if (code<0)
{
return CallNextHookEx(gHook,code,wparam,lparam);
}
//处理代码
return CallNextHookEx(gHook,code,wparam,lparam);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Minimum DLL Version user32.dll
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
Unicode Implemented as Unicode version.
自己看吧,MSDN说明,Windows.h 和Winuser.h,注意你的工程是否是Unicode 版
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
Unicode Implemented as Unicode version.
自己看吧,MSDN说明,Windows.h 和Winuser.h,注意你的工程是否是Unicode 版
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是UnhookWindowsHookEx,你弄错了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询