• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Close Internet Explorer

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
Dark_King
Asked:
Dark_King
  • 2
1 Solution
 
intheCommented:
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
 
intheCommented:
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
 
EpsylonCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now