在vc++中用mfc作regular dll 
是关于hook的;;;;;;
  g_hhook = ::SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC) KeyboardProc, theApp.m_hInstance, 0);
就是这句
错误提示: error C2440: 'type cast' : cannot convert from '' to 'long (__stdcall *)(int,unsigned int,long)'
        None of the functions with this name in scope match the target type哪里有错啊;;;具体代码:
#pragma data_seg("Shared")
HHOOK g_hhook=NULL;
#pragma data_seg()LRESULT WINAPI CS3DHookApp::KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{/*BOOL bKeyUp = lParam & (1 << 31);
if (bKeyUp && wParam == VK_F12 && nCode == HC_ACTION) {
AfxMessageBox("ok");
}return ::CallNextHookEx(g_hhook, nCode, wParam ,lParam);
*/}
BOOL  _declspec(dllexport) WINAPI CS3DHookApp::InstallHook()
{
if (g_hhook != NULL) 
    return false;
  g_hhook = ::SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC) KeyboardProc, theApp.m_hInstance, 0);return g_hhook!=NULL;
}BOOL  _declspec(dllexport) WINAPI  CS3DHookApp::UninstallHook()
{
return ::UnhookWindowsHookEx(g_hhook);
}
关键就这一个错误。。其他错误自己纠正了

解决方案 »

  1.   

    >>None of the functions with this name in scope match the target type
    意思在上下文中找不到KeyboardProc函数把KeyboardProc函数定义成static的
      

  2.   

    LRESULT CALLBACK KeyboardProc(
      int code,       // hook code
      WPARAM wParam,  // virtual-key code
      LPARAM lParam   // keystroke-message information
    );
    不在类中
      

  3.   

    加上了static 果然成功啦阿里嘎都。。呵呵。。不过为啥要加啊。。我看了其他人好多程序没有说要加啊。。为什么要加
      

  4.   

    这是回调函数的限制,需要是全局的,而类的static成员函数则满足了这一点。