Solved

Close Internet Explorer

Posted on 2001-06-21
3
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
QRReport  TQrmemo vertical stretching 1 57
LAN or WAN ? 11 106
Delphi: Connect to running MS Outlook 4 165
Typecasting TBytes to Integer in Delphi XE8 2 38
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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