home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l430 / 1.ddi / CHAP4.ZIP / NUMTASKS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-09  |  1.1 KB  |  43 lines

  1. /*
  2.     NUMTASKS.C
  3.  
  4.     From Chapter 4 of "Undocumented Windows" (Addison Wesley 1992)
  5.     by Andrew Schulman, Dave Maxey and Matt Pietrek
  6.         
  7.     Build using: WINIOBC NUMTASKS (for Borland C++ v3.00)
  8.                  WINIOMS NUMTASKS (for Microsoft C/SDK)
  9. */
  10.  
  11. #include "windows.h"
  12. #include "winio.h"
  13. #include "wmhandlr.h"
  14.  
  15. static WORD numtasks=0;
  16.  
  17. long on_time(HWND hwnd, unsigned message, WORD wParam, LONG lParam)
  18. {
  19.     WORD num;
  20.     if ((num = GetNumTasks()) != numtasks)
  21.     {
  22.         numtasks = num;
  23.         winio_clear(hwnd);
  24.         printf("%u tasks running\n", numtasks);
  25.     }
  26.     return 0;
  27. }
  28.         
  29. int main()
  30. {
  31.     HWND hwnd = winio_current();
  32.     winio_about("NUMTASKS\nMonitors current tasks"
  33.         "\n\nFrom Chapter 4 of"
  34.         "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
  35.         "\nby Andrew Schulman, David Maxey and Matt Pietrek");
  36.     wmhandler_set(hwnd, WM_TIMER, on_time);
  37.     if (! SetTimer(hwnd, 1, 1000, NULL)) // once a second
  38.         fail("can't create timer");
  39.     // go resident by falling off the end of main
  40.     return 0;
  41. }
  42.  
  43.