home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / killfold.zip / KILLFOLD.C < prev    next >
C/C++ Source or Header  |  1995-06-08  |  2KB  |  50 lines

  1. /****************************************************************/
  2. /* A quick and dirty little program to close all active windows */
  3. /* David J. Looney 27 May 1995                                  */
  4. /* 75246.3364@compuserve.com   DJLOON@delphi.com                */
  5. /* Use at your own risk.  The author assumes absolutely no      */
  6. /* liability for suitability, performance, or security of your  */
  7. /* data or system.  Public Domain.  Freeware.                   */
  8. /****************************************************************/
  9.  
  10. #define INCL_WINWORKPLACE       /* Window Workplace Shell Functions */
  11. #define INCL_WINWINDOWMGR       /* Window Manager Functions     */
  12.  
  13. #include <os2.h>
  14. #include <stdio.h>
  15. #include <alloc.h>
  16. #include <string.h>
  17. #include <stdlib.h>
  18.  
  19. HWND   hwndNext;       /* current enumeration handle           */
  20. HWND   hwndWPS;        /* WPS / Bottom Desktop Folder handle   */
  21. HENUM  henum;          /* enumeration handle                   */
  22. BOOL   fSuccess;       /* success indicator                    */
  23. SHORT  sRetLen;        /* returned string length               */
  24. LONG  lLength=1024L;   /* Length of pchBuffer */
  25. PCH   pchBuffer;       /* Class name */
  26. LONG  lRetLen;         /* Returned class name length */
  27.  
  28. main()
  29. {
  30.     pchBuffer=(PCH) malloc(lLength*sizeof(long));
  31.  
  32.     hwndWPS = WinQueryWindow(HWND_DESKTOP, QW_BOTTOM);
  33.     henum = WinBeginEnumWindows(HWND_DESKTOP);
  34.     while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE) {
  35.         lRetLen = WinQueryClassName(hwndNext, lLength, pchBuffer);
  36.         if (hwndNext!=hwndWPS){
  37.             if(strcmp((char*) pchBuffer, "wpFolder window")==0){
  38.                 WinSetFocus(HWND_DESKTOP,hwndNext);
  39.                 WinPostMsg(hwndNext,WM_CLOSE,NULL,NULL);
  40.             }
  41.         }
  42.     }
  43.     fSuccess = WinEndEnumWindows(henum);
  44.     exit(fSuccess);
  45. }
  46.  
  47.  
  48.  
  49.  
  50.