为什么在DLL的窗口中加入WebBrowser程序就出错
在网上找到了一个示例代码,大概功能是注入到XP下的"计算器"里一个DLL,可以用热键"HOME"呼出窗口,但是在DLL的窗口中,加入WebBrowser后,呼出即出错,高人帮忙看下问题出在哪?
全套代码下载
http://tj.disk1.ftn.qq.com/ftn_handler/8f4580155cf02d1484ee19f8d950aa6e765ed1eb9030242724855667bb3c19b5aa8810dccc0f3f776ec5aaf10b8127e2f12d67c3c5756163d27b025365d95ba0/?fname=xxzd_75037_75037.rar
DLL
library _core;
uses
SysUtils,
Windows,
Classes,
Forms,
uworkfom in 'uworkfom.pas' {WorkForm},
uConst in 'uConst.pas';
{$R *.res}
var
keyHHK: HHOOK;
//键盘HOOK回调函数
function GameKeyboardProc(icode, wp, lp: integer): DWORD; stdcall;
begin
if (icode = HC_ACTION) then
begin
if icode < 0 then
CallNextHookEx(0, icode, wp, lp);
//1左移31位 && lp 为0,表示按键按下
if (wp = VK_HOME) and ((1 shl 31) and lp = 0) then
begin
if WorkForm = nil then
WorkForm := TWorkForm.Create(nil)
else
WorkForm.Visible := not WorkForm.Visible;
end;
end;
GameKeyboardProc := CallNextHookEx(keyHHK, icode, wp, lp);
end;
function SetHook(): Boolean; stdcall;
var
h: HWND;
gTid: THandle;
res: Boolean;
begin
h := FindWindow(ExeClassName, ExeCaption);
res := False;
if h > 0 then
begin
gTid := GetWindowThreadProcessId(h);
keyHHK := SetWindowsHookEx(WH_KEYBOARD, @GameKeyboardProc,
GetModuleHandle(DLLName), gTid);
if keyhhk > 0 then
res := True;
end;
Result := res;
end;
function DllEnterProc(reason: integer): Boolean;
begin
case reason of
DLL_PROCESS_ATTACH:
begin
end;
DLL_PROCESS_DETACH:
begin
FreeAndNil(WorkForm);
if keyHHK > 0 then
UnhookWindowsHookEx(keyHHK);
end;
end;
Result := True;
end;
exports
GameKeyboardProc, SetHook;
begin
DllProc := @DllEnterProc;
end.
program xxzd;
uses
Forms,
Windows,
ShellAPI,
shell in 'shell.pas' {FormMain};
{$R *.res}
procedure MyMutex;
var
mutexHandle, h_Wnd: THandle;
fi: FLASHWINFO;
begin
MutexHandle := CreateMutex(nil, TRUE, '___myXXZD');
if (MutexHandle <> 0) and (GetlastError = ERROR_ALREADY_EXISTS) then
begin
h_Wnd := FindWindow(nil, 'xxzd');
if (h_Wnd > 0) then
begin
fi.hwnd := h_Wnd;
fi.cbSize := SizeOf(FLASHWINFO);
fi.dwFlags := FLASHW_ALL;
fi.uCount := 4;
fi.dwTimeout := 80;
MessageBeep(MB_ICONEXCLAMATION);
FlashWindowEx(fi);
SetForegroundWindow(h_Wnd);
Application.MessageBox('程序已在运行中','');
end;
ReleaseMutex(mutexHandle);
Halt;
end;
end;
begin
MyMutex;
Application.Initialize;
Application.Title := 'xxzd';
Application.CreateForm(TFormMain, FormMain);
Application.Run;
end.
initialization OleInitialize(nil);
finalization OleUninitialize;