Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Licz(const unsigned int LiczbaProcesow)
- {
- PROCESS_INFORMATION *pi = new PROCESS_INFORMATION[LiczbaProcesow];
- STARTUPINFO *si = new STARTUPINFO[LiczbaProcesow];
- HANDLE *handle = new HANDLE[LiczbaProcesow];
- //SECURITY_ATTRIBUTES sa;
- //memset(&sa, 0, sizeof(sa));
- // sa.nLength = sizeof(sa);
- for(unsigned int i = 0; i < LiczbaProcesow; ++i)
- {
- ZeroMemory( &pi[i], sizeof( pi[i] ) );
- ZeroMemory( & si[i], sizeof( si[i] ) );
- si[i].cb = sizeof( si[i] );
- }
- for(unsigned int i = 0; i < LiczbaProcesow; ++i)
- {
- if( !CreateProcess( NULL, ( LPSTR ) "komiwojazer1.exe", NULL, NULL, FALSE, 0, NULL, NULL, & si[i], & pi[i] ) )
- {
- printf( "Could not create %d process . (%ld)", i + 1, GetLastError() );
- _getch();
- return;
- }
- handle[i] = pi[i].hProcess;
- }
- WaitForMultipleObjects(LiczbaProcesow, handle, TRUE, INFINITE);
- for(unsigned int i = 0; i < LiczbaProcesow; ++i)
- {
- CloseHandle( pi[i].hProcess );
- CloseHandle( pi[i].hThread );
- }
- delete [] pi;
- delete [] si;
- delete [] handle;
- }
Add Comment
Please, Sign In to add comment