Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // lab5.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <Windows.h>
- using namespace std;
- //lab5
- /*int _tmain(int argc, _TCHAR* argv[])
- {
- DWORD priority_class;
- STARTUPINFO si = { sizeof(si) };
- PROCESS_INFORMATION pi;
- TCHAR czCommandLine[] = "Notepad";
- CreateProcess(NULL, czCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
- priority_class = GetPriorityClass(pi.hProcess);
- cout << "pid: " << pi.dwProcessId << endl;
- cout << "priority class: " << priority_class << endl;
- system("pause");
- return 0;
- }*/
- //lab6
- /*int _tmain(int argc, _TCHAR* argv[])
- {
- STARTUPINFO si = { sizeof(si) };
- PROCESS_INFORMATION pi;
- TCHAR czCommandLine[] = "Notepad";
- CreateProcess(NULL, czCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
- cout << "Thread id: " << pi.dwThreadId << endl;
- system("pause");
- return 0;
- }*/
- //lab7
- DWORD WINAPI ThreadProc(CONST LPVOID lpParam) {
- HANDLE thread_handle = GetCurrentThread();
- DWORD thread_priority = GetThreadPriority(thread_handle);
- bool cycle = true;
- while (cycle)
- {
- cout << "Thread priority: " << thread_priority << endl;
- Sleep(1000);
- }
- return 0;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- STARTUPINFO si = { sizeof(si) };
- PROCESS_INFORMATION pi;
- DWORD thread_id;
- TCHAR czCommandLine[] = "Notepad";
- CreateProcess(NULL, czCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
- cout << "main thread id: " << pi.dwThreadId << endl;
- CreateThread(0, 0, &ThreadProc, 0, 0, &thread_id);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement