Solved

Close Internet Explorer

Posted on 2001-06-21
3
204 Views
Last Modified: 2010-05-18
Need help to make Procedure?s

1: Close Internet Explorer from Delphi5 Program
2: Minimize Internet Explorer from Delphi5 Program

Need quick help to make this 2 Procedure?s  
0
Comment
Question by:Dark_King
  • 2
3 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 6216661
Hi,
heres some examples:


procedure CloseIExplorer(h : HWND);
Var pID,hProcess:DWord;
Begin
GetWindowThreadProcessId(h,@pID);
hProcess:=OpenProcess(PROCESS_TERMINATE,TRUE,pID);
TerminateProcess(hProcess,1);
End;

//TO KILL THE PROCESS
procedure TForm1.Button1Click(Sender: TObject);
Var
 IExplorer : Thandle;
begin
 IExplorer := FindWindow('IEFrame',nil);
 If IExplorer <> 0 Then
CloseIExplorer(IExplorer);
 end;

 //TO CLOSE NICELY
 procedure TForm1.Button2Click(Sender: TObject);
Var
 IExplorer : Thandle;
begin
 IExplorer := FindWindow('IEFrame',nil);
 If IExplorer <> 0 Then
  SendMessage(IExplorer, WM_SYSCOMMAND,SC_CLOSE,0);
 end;

//TO MINIMIZE
procedure TForm1.Button3Click(Sender: TObject);
Var
 IExplorer : Thandle;
begin
 IExplorer := FindWindow('IEFrame',nil);
 If IExplorer <> 0 Then
 SendMessage(IExplorer, WM_SYSCOMMAND,SC_MINIMIZE,0);
 end;


end.
0
 
LVL 17

Accepted Solution

by:
inthe earned 200 total points
ID: 6216680
although it is better to use postmessage:


 //TO CLOSE
 procedure TForm1.Button1Click(Sender: TObject);
Var
 IExplorer : Thandle;
begin
 IExplorer := FindWindow('IEFrame',nil);
 If IExplorer <> 0 Then
  PostMessage(IExplorer, WM_CLOSE,0,0);
 end;

//TO MINIMIZE
procedure TForm1.Button2Click(Sender: TObject);
Var
 IExplorer : Thandle;
begin
 IExplorer := FindWindow('IEFrame',nil);
 If IExplorer <> 0 Then
 PostMessage(IExplorer,WM_SYSCOMMAND, SC_MINIMIZE,0);
 end;

Regards Barry
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6217341
You can also use DDE for closing IE:

procedure TForm1.Button1Click(Sender: TObject);
var
 DDEClient : TDDEClientConv;
 str: PChar;
begin
 DDEClient := TDDEClientConv.Create(nil);
 with DDEClient do
 begin
   SetLink('iexplore', 'WWW_Exit');
   str := RequestData('0xFFFFFFFF');
   StrDispose(str);
   CloseLink;
 end;
 DDEClient.Free;
end;


See this link for more information:

http://support.microsoft.com/support/kb/articles/Q160/9/57.ASP



This shows the current URL:

procedure TForm1.Button1Click(Sender: TObject);
var
 DDEClient : TDDEClientConv;
 str: PChar;
begin
 DDEClient := TDDEClientConv.Create(nil);
 with DDEClient do
 begin
   SetLink('iexplore', 'WWW_GetWindowInfo');
   str := RequestData('0xFFFFFFFF');
   Label1.Caption := str;
   StrDispose(str);
   CloseLink;
 end;
 DDEClient.Free;
end;
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question