Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <windows.h>
- #include <io.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <iostream>
- #include <string>
- LPWSTR konwertuj(char* tekst);
- /*
- PRIORYTETY PROCESOW:
- REALTIME_PRIORITY_CLASS
- HIGH_PRIORITY_CLASS
- NORMAL_PRIORITY_CLASS
- IDLE_PRIORITY_CLASS
- PRIORYTETY WATKOW:
- THREAD_PRIORITY_ABOVE_NORMAL 1
- THREAD_PRIORITY_BELOW_NORMAL -1
- THREAD_PRIORITY_HIGHEST 2
- THREAD_PRIORITY_IDLE -15
- THREAD_PRIORITY_LOWEST -2
- THREAD_PRIORITY_NORMAL 0
- THREAD_PRIORITY_TIME_CRITICAL 15
- */
- int main(int argc, char **argv)
- {
- PROCESS_INFORMATION pi;
- STARTUPINFO si;
- ZeroMemory(&pi, sizeof(pi));
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
- std::string dana = argv[0];
- for (int i = 1; i < argc-1; i++)
- {
- dana.append(" ");
- dana.append(argv[i + 1]);
- }
- char* cstr = new char(100);
- strcpy(cstr, dana.c_str());
- LPWSTR sciezka = konwertuj(cstr);
- int process_created = 0;
- if (argc >= 1)
- {
- while (process_created < atoi(argv[1]))
- {
- CreateProcess(NULL, cstr, NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi);
- process_created++;
- std::cout << dana;
- }
- WaitForSingleObject(pi.hProcess, INFINITE);
- }
- else
- Sleep(10000);
- delete cstr;
- CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
- ExitProcess(0);
- return 0;
- }
- LPWSTR konwertuj(char* tekst)
- {
- wchar_t konw[100];
- mbstowcs(konw, tekst, strlen(tekst) + 1); //konwersja na windowsowy string
- LPWSTR sciezka = konw;
- return sciezka;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement