First commit 19/07/1998
This commit is contained in:
34
CDopping/ActvApp/CloseApp.pas
Normal file
34
CDopping/ActvApp/CloseApp.pas
Normal file
@ -0,0 +1,34 @@
|
||||
unit CloseApp;
|
||||
|
||||
{ By Duncan McNiven, duncan.mcniven@lecs.inet.fi }
|
||||
{ Comments by Brad Stowers, bstowers@pobox.com }
|
||||
|
||||
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; export;
|
||||
begin
|
||||
Result := TRUE; { continue enumeration }
|
||||
{ Does this app have the same instance as what we are looking for? }
|
||||
if GetWindowWord(Handle, GWL_HINSTANCE) = LongInt(Info) then begin
|
||||
PostMessage(Handle, WM_CLOSE, 0, 0); { Close the app }
|
||||
Result := FALSE; { stop enumerating windows, we are done. }
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CloseAppFromInst(HInst: THandle);
|
||||
begin
|
||||
EnumWindows(@EnumWindowsProc, LongInt(HInst));
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user