home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / swlist.zip / WINLIST.C < prev   
C/C++ Source or Header  |  1993-03-22  |  4KB  |  97 lines

  1. #include <string.h>
  2. #include <stdio.h>
  3.  
  4. #define INCL_BASE
  5. #define INCL_WIN
  6. #define INCL_DOS
  7. #include <os2.h>
  8.  
  9.  
  10. void ListTaskListEntry(void);
  11.  
  12. /************************************************************************/
  13. /*                                                                      */
  14. /* Function : main: list                                                */
  15. /*                                                                      */
  16. /* Purpose  : This function list tasklist entries                       */
  17. /*                                                                      */
  18. /* Input    : none                                                      */
  19. /*                                                                      */
  20. /* Output   : none                                                      */
  21. /*                                                                      */
  22. /************************************************************************/
  23. int main
  24. (
  25.     int                argc,
  26.     char              *argv[]
  27. )
  28. {
  29.     ListTaskListEntry();
  30.  
  31.     return (0);
  32. }
  33.  
  34. /************************************************************************/
  35. /*                                                                      */
  36. /* Function : ListTaskListEntry                                         */
  37. /*                                                                      */
  38. /* Purpose  : The task list (shown by Ctrl ESC) is listed               */
  39. /*                                                                      */
  40. /* Input    : none                                                      */
  41. /*                                                                      */
  42. /* Output   : none                                                      */
  43. /*                                                                      */
  44. /************************************************************************/
  45. void ListTaskListEntry
  46. (
  47.     void
  48. )
  49. {
  50.     FILE              *wlist;
  51.     USHORT             i;
  52.     size_t             usSWBSize;
  53.     USHORT             count;
  54.     PSWBLOCK           ppswblk;
  55.     HAB                hab;
  56.  
  57.     if ((hab = WinInitialize( 0L)) != NULLHANDLE) /* start PM session        */
  58.     {
  59.         count = WinQuerySwitchList(hab, NULL, 0);
  60.         if (count > 0)
  61.         {
  62.             printf( "Windowlist entries: %u\n\n", count);
  63.             usSWBSize = (count * sizeof(SWBLOCK));
  64.             if ((ppswblk = (SWBLOCK*) malloc( usSWBSize)) != NULL)
  65.             {
  66.                 printf( "%4.4s %8.8s %8.8s %4.4s %3.3s %1.1s %1.1s %-s\n",
  67.                         "hsw",
  68.                         "hwnd",
  69.                         "hwndIcon",
  70.                         "PID",
  71.                         "SID",
  72.                         "V",
  73.                         "J",
  74.                         "szSwtitle"
  75.                       );
  76.                 count = WinQuerySwitchList(hab, ppswblk, usSWBSize);
  77.                 for (i = 0; i < count; i++)
  78.                 {
  79.                     printf( "%4.4X %8.8x %8.8x %4.4x %3.3x %1.1x %1.1x %-s\n",
  80.                             ppswblk->aswentry[i].hswitch,
  81.                             ppswblk->aswentry[i].swctl.hwnd,
  82.                             ppswblk->aswentry[i].swctl.hwndIcon,
  83.                             ppswblk->aswentry[i].swctl.idProcess,
  84.                             ppswblk->aswentry[i].swctl.idSession,
  85.                             ppswblk->aswentry[i].swctl.uchVisibility,
  86.                             ppswblk->aswentry[i].swctl.fbJump,
  87.                             ppswblk->aswentry[i].swctl.szSwtitle
  88.                           );
  89.                 }
  90.                 free( ppswblk);
  91.             }
  92.         }
  93.         WinTerminate(hab);
  94.     }
  95. }                                              // einde 'ListTaskListEntry'
  96. /*---------------------------------------------------------------------------*/
  97.