當我用程序
if not EnableMouseHook(handle, GetCurrentProcessID,Application.Handle) then
ShowMessage('ERROR')
else
SetCaptureFlag(TRUE);當系統是win98+delphi6時,調用 GFDict.DLL中的 EnableMouseHook 函數時總是通不過,
問題就是在RegisterClass這裡,但是在系統是winXP+delphi6的時候就可以通過,不知是何原因??GFDict.DLL 部分代碼如下:
function EnableMouseHook(hld:hwnd; ProcessID : DWORD; hInst:THandle): BOOL; export;
begin
Result := False;
if hNextHookProc <> 0 then Exit; hNextHookProc := SetWindowsHookEx(WH_MOUSE, MousePosHookHandler,Hinstance, 0);
// GetWindowThreadProcessID(hWnd, nil)); InitCoverWindow(hInst); if CommonData <> nil then begin
CommonData^.CallBackHandle := hld;
CommonData^.CallBackProcID := ProcessID;
end;
Result :=hNextHookProc <> 0 ;
end;
procedure InitCoverWindow(hInst : LongWord);
var
WndClass : TWndClass; //Ex;
//WndClass : TWndClassEx;
begin
with WndClass do begin
style := WS_EX_TOPMOST;
lpfnWndProc := @CoverMainProc; (*秏洘揭燴滲杅*)
hInstance := hInst;
hbrBackground := color_btnface + 1;
lpszClassname := 'GanFreeDict';
hicon := 0;
hCursor := 0;
cbClsExtra := 0;
cbWndExtra := 0;
end; try
//if not BOOL(RegisterClass{Ex}(WndClass)) then begin
if not BOOL(RegisterClass{Ex}(WndClass)) then begin
MessageBox(0,
PChar(Format('$EEEE, Can not register class CHILD %d',[GetLastError])),
'Register Error',
MB_OK);
end;
except
MessageBox(0, 'EXCEPTION', 'Register Class', MB_OK);
end; hWndCover := CreateWindowEx(WS_EX_TOPMOST or WS_EX_TOOLWINDOW,
'GanFreeDict',
'^_^',
WS_POPUP or WS_VISIBLE,
-1,-1,1,1,
0,
0,
hInst, // GetModuleHandle('dll.dll'), // 98 for this, 2000 for 0
nil); if CommonData<>nil then begin
CommonData^.hWndFloat := hWndCover;
end;
SetTimer(hWndCover, 1, 450, @WndCoverTimer);
end;
if not EnableMouseHook(handle, GetCurrentProcessID,Application.Handle) then
ShowMessage('ERROR')
else
SetCaptureFlag(TRUE);當系統是win98+delphi6時,調用 GFDict.DLL中的 EnableMouseHook 函數時總是通不過,
問題就是在RegisterClass這裡,但是在系統是winXP+delphi6的時候就可以通過,不知是何原因??GFDict.DLL 部分代碼如下:
function EnableMouseHook(hld:hwnd; ProcessID : DWORD; hInst:THandle): BOOL; export;
begin
Result := False;
if hNextHookProc <> 0 then Exit; hNextHookProc := SetWindowsHookEx(WH_MOUSE, MousePosHookHandler,Hinstance, 0);
// GetWindowThreadProcessID(hWnd, nil)); InitCoverWindow(hInst); if CommonData <> nil then begin
CommonData^.CallBackHandle := hld;
CommonData^.CallBackProcID := ProcessID;
end;
Result :=hNextHookProc <> 0 ;
end;
procedure InitCoverWindow(hInst : LongWord);
var
WndClass : TWndClass; //Ex;
//WndClass : TWndClassEx;
begin
with WndClass do begin
style := WS_EX_TOPMOST;
lpfnWndProc := @CoverMainProc; (*秏洘揭燴滲杅*)
hInstance := hInst;
hbrBackground := color_btnface + 1;
lpszClassname := 'GanFreeDict';
hicon := 0;
hCursor := 0;
cbClsExtra := 0;
cbWndExtra := 0;
end; try
//if not BOOL(RegisterClass{Ex}(WndClass)) then begin
if not BOOL(RegisterClass{Ex}(WndClass)) then begin
MessageBox(0,
PChar(Format('$EEEE, Can not register class CHILD %d',[GetLastError])),
'Register Error',
MB_OK);
end;
except
MessageBox(0, 'EXCEPTION', 'Register Class', MB_OK);
end; hWndCover := CreateWindowEx(WS_EX_TOPMOST or WS_EX_TOOLWINDOW,
'GanFreeDict',
'^_^',
WS_POPUP or WS_VISIBLE,
-1,-1,1,1,
0,
0,
hInst, // GetModuleHandle('dll.dll'), // 98 for this, 2000 for 0
nil); if CommonData<>nil then begin
CommonData^.hWndFloat := hWndCover;
end;
SetTimer(hWndCover, 1, 450, @WndCoverTimer);
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货