Re: Closing a program

Posted by Met@ on August 31, 2002

In Reply to: Re: Closing a program posted by Met@ on August 31, 2002

: : //Use this to close all open IE windows.

: : Var
: : IExplorer : Thandle;
: : begin
: : IExplorer := FindWindow(''IEFrame'',nil);
: : If IExplorer <> 0 Then
: : SendMessage(IExplorer, WM_SYSCOMMAND,SC_CLOSE,0);

: : //note instead of SC_CLOSE

: : //SC_MINIMIZE can be used to minimize all ie windows
: : //SC_MAXIMIZE can be used to maximize all ie windows

: : //This could be used on a button click or in a timer for example.

: : I think this is what I was looking for...yes! IT IS! Thanks for your help anyhow! :D :D :D <(^_^)>

: : Met@

: Whoops! I cheered too early......LOL IT DOESN'T WORK! *pulling hair out of head*
: Can you pleaaaaaaaaase help me?
: *sigh*

: TIA
: Met@

---------------------------------------------

Hey! IT DOES WORK! It just doesn't work with the windows that just opened.......LOL Look:

procedure TForm1.Button1Click(Sender: TObject);
Var IExplore : Thandle;
begin
  ShellExecute(Handle, 'open', 
    PChar('D:\Program Files\Microsoft Office\Office\OUTLOOK.EXE'), nil, nil, SW_SHOW);
  ShellExecute(Handle, 'open', 
    PChar('D:\Program Files\Outlook Express\MSIMN.EXE'), nil, nil, SW_SHOW);
  ShellExecute(Handle, 'open', 
    PChar('D:\Program Files\Internet Explorer\IEXPLORE.EXE'), 
    PChar('http://thesimssite.endoria.net/indexECHT.htm'), nil, SW_SHOW);
  ShellExecute(Handle, 'open', 
    PChar('D:\Program Files\Internet Explorer\IEXPLORE.EXE'), 
    PChar('http://thesimssite.endoria.net/CC/phpBB2/index.php'), nil, SW_SHOW);
  ShellExecute(Handle, 'open', 
    PChar('D:\Program Files\Internet Explorer\IEXPLORE.EXE'), 
    PChar('http://www.the-forums.nl'), nil, SW_SHOW);
  IExplore := FindWindow('IEFrame',nil);
  If IExplore <> 0 Then
    PostMessage(IExplore, WM_SYSCOMMAND,SC_CLOSE,0);
end;

That DOES work, but it only closes the windows that were already open! But nevermind that ;) I thought of another way......LOL I wanted my IE to close for some weird reasons......... had to do with the order of the programs on my start bar LOL IE opened faster than my mail programs, so IE had to close... LOL But I can build in a timer! *DUH*
So, I'm gonna try that now! :D

Met@


Related Articles and Replies:


Find related articles

Search for:  shellexecute 


Delphi Forum :: Tutorials :: Source code :: Tips