--- q_a/samples/threads/threads.c 2018/08/09 18:29:19 1.1.1.1 +++ q_a/samples/threads/threads.c 2018/08/09 18:29:58 1.1.1.2 @@ -1,3 +1,14 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + /*************************************************************************\ * PROGRAM: Threads.c * @@ -61,7 +72,7 @@ int APIENTRY WinMain (HANDLE hInstance, hInst = hInstance; - wc.style = NULL; // Replaces CS_SIZEREDRAW. + wc.style = 0; // Replaces CS_SIZEREDRAW. wc.lpfnWndProc = (WNDPROC)MainWndProc; // The client window procedure. wc.cbClsExtra = 0; // No room reserved for extra data. wc.cbWndExtra = 0; @@ -89,7 +100,7 @@ int APIENTRY WinMain (HANDLE hInstance, ShowWindow(hWnd, nCmdShow); - while (GetMessage (&msg, NULL, NULL, NULL)) + while (GetMessage (&msg, NULL, 0, 0)) DispatchMessage (&msg); // Dispatch message to window. return (msg.wParam); // Returns value from PostQuitMessage. @@ -145,11 +156,11 @@ int APIENTRY WinMain (HANDLE hInstance, * number of suspensions. * * IDM_G***: -* These 5 messages use SetThreadPriority to set the +* These 7 messages use SetThreadPriority to set the * priority of the Green Thread. * * IDM_R***: -* These 5 messages use SetThreadPriority to set the +* These 7 messages use SetThreadPriority to set the * priority of the Red Thread. * * CALLED BY: @@ -187,7 +198,7 @@ LONG APIENTRY MainWndProc (HWND hwnd, *pColor1 = GREEN; hThread1 = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, - (LPVOID)pColor1, NULL, + (LPVOID)pColor1, 0, (LPDWORD)&ThreadID1); if (!hThread1) @@ -204,7 +215,7 @@ LONG APIENTRY MainWndProc (HWND hwnd, *pColor2 = RED; hThread2 = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, - (LPVOID)pColor2, NULL, + (LPVOID)pColor2, 0, (LPDWORD)&ThreadID2); if (!hThread2) { @@ -254,7 +265,12 @@ LONG APIENTRY MainWndProc (HWND hwnd, return (0); - case IDM_GLOW: // Sets green lowest possible. + case IDM_GIDLE: // Sets green idle. + SetThreadPriority (hThread1, THREAD_PRIORITY_IDLE); + return (0); + + + case IDM_GLOW: // Sets green lowest. SetThreadPriority (hThread1, THREAD_PRIORITY_LOWEST); return (0); @@ -270,10 +286,20 @@ LONG APIENTRY MainWndProc (HWND hwnd, SetThreadPriority (hThread1, THREAD_PRIORITY_ABOVE_NORMAL); return (0); - case IDM_GHIGH: // Sets green to highest possible. + case IDM_GHIGH: // Sets green to highest. SetThreadPriority (hThread1, THREAD_PRIORITY_HIGHEST); return (0); + case IDM_GTC: // Sets green time critical. + SetThreadPriority (hThread1, THREAD_PRIORITY_TIME_CRITICAL); + return (0); + + + + + case IDM_RIDLE: // Sets red idle. + SetThreadPriority (hThread1, THREAD_PRIORITY_IDLE); + return (0); case IDM_RLOW: // Sets red to lowest possible SetThreadPriority (hThread2, THREAD_PRIORITY_LOWEST); @@ -295,6 +321,10 @@ LONG APIENTRY MainWndProc (HWND hwnd, SetThreadPriority (hThread2, THREAD_PRIORITY_HIGHEST); return (0); + case IDM_RTC: // Sets green time critical. + SetThreadPriority (hThread1, THREAD_PRIORITY_TIME_CRITICAL); + return (0); + default: return (0);