home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / swlist.zip / c / swlist / WINLIST.C < prev    next >
C/C++ Source or Header  |  1998-07-27  |  4KB  |  110 lines

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