Advertisement
piffy

CreateProcess_esempio

Aug 30th, 2014
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. int main ()
  2. {
  3.     STARTUPINFO si = {};
  4.     si.cb = sizeof si;
  5.  
  6.     PROCESS_INFORMATION pi = {};
  7.     const TCHAR* target = _T("c:\\WINDOWS\\system32\\calc.exe");
  8.  
  9.     if ( !CreateProcess(target, 0, 0, FALSE, 0, 0, 0, 0, &si, &pi) )
  10.     {
  11.         cerr << "Chiamata a CreateProcess non riuscita (" << GetLastError() << ").\n";
  12.     }
  13.     WaitForSingleObject(pi.hProcess,0);
  14.     cout << "Processo terminato: pulizia.\n";
  15.     CloseHandle(pi.hProcess);
  16.     CloseHandle(pi.hThread);
  17.  
  18.     cin.sync();
  19.     cin.ignore();
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement