Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. // lab5.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <Windows.h>
  7.  
  8. using namespace std;
  9.  
  10. //lab5
  11. /*int _tmain(int argc, _TCHAR* argv[])
  12. {
  13.     DWORD priority_class;
  14.     STARTUPINFO si = { sizeof(si) };
  15.     PROCESS_INFORMATION pi;
  16.     TCHAR czCommandLine[] = "Notepad";
  17.     CreateProcess(NULL, czCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
  18.     priority_class = GetPriorityClass(pi.hProcess);
  19.  
  20.     cout << "pid: " << pi.dwProcessId << endl;
  21.     cout << "priority class: " << priority_class << endl;
  22.  
  23.     system("pause");
  24.     return 0;
  25. }*/
  26.  
  27. //lab6
  28. /*int _tmain(int argc, _TCHAR* argv[])
  29. {
  30.     STARTUPINFO si = { sizeof(si) };
  31.     PROCESS_INFORMATION pi;
  32.     TCHAR czCommandLine[] = "Notepad";
  33.     CreateProcess(NULL, czCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
  34.  
  35.     cout << "Thread id: " << pi.dwThreadId << endl;
  36.  
  37.     system("pause");
  38.     return 0;
  39. }*/
  40.  
  41. //lab7
  42. DWORD WINAPI ThreadProc(CONST LPVOID lpParam) {
  43.     HANDLE thread_handle = GetCurrentThread();
  44.     DWORD thread_priority = GetThreadPriority(thread_handle);
  45.     bool cycle = true;
  46.     while (cycle)
  47.     {
  48.         cout << "Thread priority: " << thread_priority << endl;
  49.         Sleep(1000);
  50.     }
  51.     return 0;
  52. }
  53. int _tmain(int argc, _TCHAR* argv[])
  54. {  
  55.     STARTUPINFO si = { sizeof(si) };
  56.     PROCESS_INFORMATION pi;
  57.     DWORD thread_id;
  58.  
  59.     TCHAR czCommandLine[] = "Notepad";
  60.     CreateProcess(NULL, czCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
  61.     cout << "main thread id: " << pi.dwThreadId << endl;
  62.  
  63.     CreateThread(0, 0, &ThreadProc, 0, 0, &thread_id);
  64.  
  65.     system("pause");
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement