Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need close some aplication from my Delphi program

Status
Not open for further replies.

cervenan

Programmer
May 29, 2000
3
0
0
US
Hi, I'm Roman

I know handle of aplication which I want close, but I need to know some API or Delphi function to close this aplication. Please, if you know way to doing this, write me some example.

Thank's a lot
 
Two<br>SendMessage(YourHandle,WM_CLOSE,0,0);<br>or<br>DestroyWindow( YourHandle );<br><br>DestroyWindow() use for main window.<br>(excuse for my English).
 
The previous answer is pretty much accurate only....<br><br>If you don't have the handle than what, Well I had an application where I needed to close down all open browser windows, Netscape, Explorer, AOL etc. Here is how I sorted that problem<br><br>If you need further explanation just ask<br><br>Umar Sear<br><A HREF="mailto:usear@Yahoo.com">usear@Yahoo.com</A><br><br>function EnumWindowsCode(Wnd : hWnd;Form : TFrmDialler) : Boolean; Export; StdCall;<br>var<br>&nbsp;&nbsp;Buffer : Array[0..255] of char;<br>begin<br>&nbsp;&nbsp;GetWindowText(Wnd,Buffer,256);<br>&nbsp;&nbsp;if (StrLen(Buffer) &lt;&gt; 0) then<br>&nbsp;&nbsp;Begin<br>&nbsp;&nbsp;&nbsp;&nbsp;If (Pos(Explorer,StrPas(Buffer)) &lt;&gt; 0) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;Begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(BrowserCount);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BrowserList[BrowserCount]:=Wnd;<br>&nbsp;&nbsp;&nbsp;&nbsp;End;<br>&nbsp;&nbsp;&nbsp;&nbsp;If (Pos(Netscape,StrPas(Buffer)) &lt;&gt; 0) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;Begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(BrowserCount);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BrowserList[BrowserCount]:=Wnd;<br>&nbsp;&nbsp;&nbsp;&nbsp;End;<br>&nbsp;&nbsp;&nbsp;&nbsp;If (Pos(AOL,StrPas(Buffer)) &lt;&gt; 0) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;Begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(BrowserCount);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BrowserList[BrowserCount]:=Wnd;<br>&nbsp;&nbsp;&nbsp;&nbsp;End;<br>&nbsp;&nbsp;End;<br>&nbsp;&nbsp;Result := True;<br>end;<br><br>Procedure TfrmDialler.SearchNDestroy;<br>Var i : Integer;<br>Begin<br>&nbsp;EnumWindows(@EnumWindowsCode,LongInt(Self));<br>&nbsp;For i:= 1 to Browsercount Do<br>&nbsp;&nbsp;&nbsp;&nbsp;PostMessage(BrowserList<i>, WM_Close, 0, 0);<br>End;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top