Solved

Close Internet Explorer

Posted on 2001-06-21
3
195 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now