home *** CD-ROM | disk | FTP | other *** search
- /*
- NUMTASKS.C
-
- From Chapter 4 of "Undocumented Windows" (Addison Wesley 1992)
- by Andrew Schulman, Dave Maxey and Matt Pietrek
-
- Build using: WINIOBC NUMTASKS (for Borland C++ v3.00)
- WINIOMS NUMTASKS (for Microsoft C/SDK)
- */
-
- #include "windows.h"
- #include "winio.h"
- #include "wmhandlr.h"
-
- static WORD numtasks=0;
-
- long on_time(HWND hwnd, unsigned message, WORD wParam, LONG lParam)
- {
- WORD num;
- if ((num = GetNumTasks()) != numtasks)
- {
- numtasks = num;
- winio_clear(hwnd);
- printf("%u tasks running\n", numtasks);
- }
- return 0;
- }
-
- int main()
- {
- HWND hwnd = winio_current();
- winio_about("NUMTASKS\nMonitors current tasks"
- "\n\nFrom Chapter 4 of"
- "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
- "\nby Andrew Schulman, David Maxey and Matt Pietrek");
- wmhandler_set(hwnd, WM_TIMER, on_time);
- if (! SetTimer(hwnd, 1, 1000, NULL)) // once a second
- fail("can't create timer");
- // go resident by falling off the end of main
- return 0;
- }
-
-