function EnumWindowsProc(HWND: hWnd; param: pointer): Boolean; stdcall;
var
IEHWND: hWnd;
IECaption: string;
bHaveIE: Boolean;
sIETitle: string; // sIETitle:='Microsoft Internet Explorer';
function EnumWindowsProc(HWND: hWnd; param: pointer): Boolean;
var
buffer: array[0..255] of Char;
begin
GetWindowText(hWnd, buffer, 256);
if StrComp(buffer, PChar(sIETitle)) > 0 then
begin
bHaveIE := True;
IEHWND := hWnd;
这里得到了IE的句柄。然后发送WM_Close消息就可以了。
StrCopy(pChar(IECaption), buffer);
end;
Result := True;
end;