?
Solved

Close Internet Explorer

Posted on 2001-06-21
3
Medium Priority
?
217 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 800 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

765 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