haha, 你不是要做木马吧?
用系统钩子。不过XP下可能不行呀。
你可以到安全技术论坛搜索以下。

解决方案 »

  1.   

    1、用VC做个全局DLL的钩子,代码如下:
    KEYHOOK.C#include <windows.h>
    #include <windowsx.h>
    #include <tchar.h>HINSTANCE g_hinstDll = NULL;#pragma data_seg(".drectve")
        static char szLinkDirectiveShared[] = "-section:Shared,rws";
    #pragma data_seg()
    #pragma data_seg("Shared")HHOOK g_hhook      = NULL;
    HWND  g_hwndPost   = NULL;
    UINT  g_uMsgNotify = WM_USER;#pragma data_seg()static LRESULT WINAPI KeyboardHook_HookProc (
       int nCode,
       WPARAM wParam, 
       LPARAM lParam) 
    {   LRESULT lResult = CallNextHookEx(g_hhook, nCode, wParam, lParam);   if (nCode == HC_ACTION) 
       {
          PostMessage(g_hwndPost, g_uMsgNotify, wParam, lParam);
       }
       return(lResult);
    }BOOL WINAPI SetKeyboardHook (HWND hWndPost, UINT Msg) 
    {
       HHOOK hhook;   if (g_hhook != NULL) return(FALSE);   g_hwndPost   = hWndPost;
       g_uMsgNotify = Msg;
       Sleep(0);   hhook = SetWindowsHookEx(WH_KEYBOARD, KeyboardHook_HookProc, g_hinstDll, 0);
       InterlockedExchange((PLONG) &g_hhook, (LONG) hhook);
       return(g_hhook != NULL);
    }BOOL WINAPI ReleaseKeyboardHook() 
    {
       BOOL fOK = TRUE;   if (g_hhook != NULL) 
       {
          fOK = UnhookWindowsHookEx(g_hhook);
          g_hhook = NULL;
       }
       return(fOK);
    }BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) 
    {
       switch (fdwReason) 
       {
          case DLL_PROCESS_ATTACH:
             g_hinstDll = hinstDll;
             break;
       }
       return(TRUE);
    }KEYHOOK.DEFEXPORTS
       SetKeyboardHook
       ReleaseKeyboardHook2、在VB中使用:
    Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Public Declare Function SetKeyboardHook Lib "KeybHook" (ByVal hwndPost As Long, ByVal Msg As Long) As Long
    Public Declare Function ReleaseKeyboardHook Lib "KeybHook" () As Long