想写一个键盘记录程序,使用hook, 打算作成一个service,不过对service编写不熟,有没有简单的解决方案?

解决方案 »

  1.   

    yes,hwo to implement it as a service ,you can see
    http://www.codeguru.com/system/nt_service.shtml
      

  2.   

    hook要在service运行的什么阶段装载呢?我按照这个作了一下,装载函数调用了,但是钩子处理函数一直没有调用,怎么做?
      

  3.   

    thus i use MFC service ,you can write code such as
    //启动服务
    void CServiceApp :: Run( DWORD, LPTSTR *) 
    { // args not used in this small example
    // report to the SCM that we're about to start
    ReportStatus(SERVICE_START_PENDING);
    m_hStop = ::CreateEvent(0, TRUE, FALSE, 0); // You might do some more initialization here.
    // Parameter processing for instance ...
     //this you can Load your hook here
             VERIFY(m_hInstance=::LoadLibrary((LPCTSTR)"test.dll"));
    FUNC_INSHOOK pFuncsethook;
    //install shell hook in process
    VERIFY(pFuncsethook=(FUNC_INSHOOK)::GetProcAddress(m_hInstance,"installkeyhook"));    
    pFuncsethook();//install keyboard Hook
    }