Guest User

Untitled

a guest
Dec 18th, 2018
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. void Licz(const unsigned int LiczbaProcesow)
  2. {
  3. PROCESS_INFORMATION *pi = new PROCESS_INFORMATION[LiczbaProcesow];
  4. STARTUPINFO *si = new STARTUPINFO[LiczbaProcesow];
  5. HANDLE *handle = new HANDLE[LiczbaProcesow];
  6. //SECURITY_ATTRIBUTES sa;
  7. //memset(&sa, 0, sizeof(sa));
  8. // sa.nLength = sizeof(sa);
  9.  
  10. for(unsigned int i = 0; i < LiczbaProcesow; ++i)
  11. {
  12. ZeroMemory( &pi[i], sizeof( pi[i] ) );
  13. ZeroMemory( & si[i], sizeof( si[i] ) );
  14. si[i].cb = sizeof( si[i] );
  15. }
  16.  
  17. for(unsigned int i = 0; i < LiczbaProcesow; ++i)
  18. {
  19. if( !CreateProcess( NULL, ( LPSTR ) "komiwojazer1.exe", NULL, NULL, FALSE, 0, NULL, NULL, & si[i], & pi[i] ) )
  20. {
  21. printf( "Could not create %d process . (%ld)", i + 1, GetLastError() );
  22. _getch();
  23. return;
  24. }
  25. handle[i] = pi[i].hProcess;
  26. }
  27.  
  28. WaitForMultipleObjects(LiczbaProcesow, handle, TRUE, INFINITE);
  29.  
  30. for(unsigned int i = 0; i < LiczbaProcesow; ++i)
  31. {
  32. CloseHandle( pi[i].hProcess );
  33. CloseHandle( pi[i].hThread );
  34. }
  35.  
  36. delete [] pi;
  37. delete [] si;
  38. delete [] handle;
  39. }
Add Comment
Please, Sign In to add comment