Bekz.net - (14014 of 825569 - 2%) 

 Home | Tips & Tricks | General Info | Downloads | NG Archive | Links | Email | Search | Register | Users | Login

 


 

Tips & Tricks

 

Rating: 60% (1 votes registred)
Rate this item:

Back to list

How can I close all open applications on my machine?

Enrico Maria Giordano gave me this great tip. Imagine a situation where you need to close all open applications on your local machine, except your own application. This is how to do it:

#define GW_HWNDFIRST 0
#define GW_HWNDLAST  1
#define GW_HWNDNEXT  2
#define GW_HWNDPREV  3
#define GW_OWNER     4
#define GW_CHILD     5
#define WM_CLOSE    16

function CloseApps( hMWnd )
LOCAL ahWnd := {}
LOCAL hWnd  := GETWINDOW( hMWnd, GW_HWNDFIRST )
LOCAL i

SysRefresh()

WHILE hWnd != 0
 IF GetWindow( hWnd, GW_OWNER ) = 0 .AND.;
    IsWindowVisible( hWnd )         .AND.;
    hWnd != hMWnd                   .AND.;
    !Empty( GetWindowsExt( hWnd ) ) .AND.;
    !( GetWindowExt( hWnd ) == "Program Manager" )
 AADD( ahWnd, hWnd )
 ENDIF
 hWnd = GetWindow( hWnd, GW_HWNDNEXT )
ENDDO

FOR i = 1 TO LEN( ahWnd )
 PostMessage( ahWnd[ i ], WM_CLOSE, 0, 0 )
NEXT

RETURN NIL
 

 

 

 

 

© 2002 Bekz.net, Inc. All Rights Reserved.