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.
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> Buffer : Array[0..255] of char;<br>begin<br> GetWindowText(Wnd,Buffer,256);<br> if (StrLen(Buffer) <> 0) then<br> Begin<br> If (Pos(Explorer,StrPas(Buffer)) <> 0) Then<br> Begin<br> Inc(BrowserCount);<br> BrowserList[BrowserCount]:=Wnd;<br> End;<br> If (Pos(Netscape,StrPas(Buffer)) <> 0) Then<br> Begin<br> Inc(BrowserCount);<br> BrowserList[BrowserCount]:=Wnd;<br> End;<br> If (Pos(AOL,StrPas(Buffer)) <> 0) Then<br> Begin<br> Inc(BrowserCount);<br> BrowserList[BrowserCount]:=Wnd;<br> End;<br> End;<br> Result := True;<br>end;<br><br>Procedure TfrmDialler.SearchNDestroy;<br>Var i : Integer;<br>Begin<br> EnumWindows(@EnumWindowsCode,LongInt(Self));<br> For i:= 1 to Browsercount Do<br> PostMessage(BrowserList<i>, WM_Close, 0, 0);<br>End;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.