我在WIN98下使用钩子技术,一调用函数SetWindowHookEx就蓝屏,吐血!!!但我的程序在NT、2K下都正常,WIN98是不是要打什么补钉呀,我的是WIN98第二版。

解决方案 »

  1.   

    回复人: wizardqi(男巫) ( ) 信誉:100  2004-07-23 09:20:00  得分: 0  
     
     
       可能是触及到了系统关键部分,代码有误,帖出来看看。
    --------------------------------------------------------------------------
    呵呵~~~~~
    to 楼主
    你贴出来看看阿
      

  2.   

    代码如下,大家帮我看看,在2K、XP下正常,WIN98就一走到SetWindowsHookEx就蓝屏了。
    type
      TShareData = record
        g_hHookKbd: HHook;
        g_Text: string;
        g_hRich: THandle;
      end;
      PShareData = ^TShareData;function StartHook(pID: THandle): DWORD; export;
    function StopHook: DWORD; export;
    function KeyBoardCallBack(Code: integer; wParam: word; lParam: Longint): LongInt;
    implementationimplementationvar
      ShareData: PShareData;function StartHook(pID: THandle): DWORD;
      function GetModuleHandleFromInstance: THandle;
      var
        s: array[0..512] of char;
      begin
        GetModuleFileName(HInstance, s, SizeOf(s) - 1);
        Result := GetModuleHandle(s);
      end;
    begin
      Result := 1;  ShareData^.g_hHookKbd := SetWindowsHookEx(WH_KEYBOARD, @KeyBoardCallBack, GetModuleHandleFromInstance, pID);
      if (ShareData^.g_hHookKbd = 0) then Result := 0;
    end;function StopHook: DWORD;
    begin
      UnhookWindowsHookEx(ShareData^.g_hHookKbd);  Result := 1;
    end;function KeyBoardCallBack(Code: integer; wParam: word; lParam: Longint): LongInt;
    begin
     
      Result := CallNextHookEx(ShareData^.g_hHookKbd, Code, wParam, lParam);
    end;
      

  3.   

    98 请使用 SetWindowHook 注意 后面的Ex表示为extended....
      

  4.   

    SetWindowsHook
    The SetWindowsHook function is obsolete. This function is provided only for compatibility with 16-bit versions of Windows. Win32-based applications should use the SetWindowsHookEx function.SetWindowsHookEx
    The SetWindowsHookEx function installs an application-defined hook procedure into a hook chain. You would install a hook procedure to monitor the system for certain types of events. These events are associated either with a specific thread or with all threads in the system. // 应该是98系统的问题
      

  5.   

    我重装了WIN98,使用的是SetWindowsHookEx,问题依旧,蓝屏,大家再帮我支点招吧.