Question:
Is it possible to close active application with another application?
How?
Answer:
Yes, it is very possible to do that. Here the source code.
Procedure CloseApp();
Begin
// this program use to close another application
// offcourse you need to lnow HInstance for application you want to close
interface
uses WinTypes;
procedure CloseAppFromInst(HInst: THandle);
implementation
uses WinProcs, Messages;
{ Callback function that has each top-level window passed to it. }
{ Return true to continue enumerating, false to stop. }
function EnumWindowsProc(Handle: HWND; Info: Pointer): boolean;
{$IFDEF WIN32} stdcall; {$ELSE} export; {$ENDIF}
begin
Result := TRUE; { continue enumeration }
{ Does this app have the same instance as what we are looking for? }
{$IFDEF WIN32}
if GetWindowLong(Handle, GWL_HINSTANCE) = LongInt(Info) then begin
{$ELSE}
if GetWindowWord(Handle, GWW_HINSTANCE) = LongInt(Info) then begin
{$ENDIF}
PostMessage(Handle, WM_CLOSE, 0, 0); { Close the app }
Result := FALSE; { stop enumerating windows, we are done. }
end;
end;
Subscribe to:
Post Comments (Atom)
0 Responses so far.
Post a Comment
Thank you for your comment.
Any request and idea are welcome.