Delphi .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Closing Internet Explorer (IE) from Delphi
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Question:
My application has to close the IE. How can an application close the Internet Explorer or an Explorer window?
Answer:
The key is to post to the *right* window. Use the code below and it will close all instances of IE.  | |  | | program Sample;
function CloseIEs(Wnd : HWnd; Form : TForm1) : Boolean; export; stdcall;
var
sCap : array [0..255] of char;
begin
GetWindowText (Wnd, sCap, sizeof(sCap));
if pos ('Microsoft Internet Explorer', sCap) > 0 then
begin
PostMessage (Wnd, WM_CLOSE, 0, 0);
end
else
begin
GetClassName (Wnd, sCap, sizeof(sCap));
if sCap = 'IEFrame' then
PostMessage (Wnd, WM_CLOSE, 0, 0);
end;
CloseIEs := true;
end;
begin
EnumWindows(@CloseIEs, 0);
end. | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|