Advertisement
Guest User

Untitled

a guest
Sep 9th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <tchar.h>
  4.  
  5. int _tmain( int argc, TCHAR *argv[] )
  6. {
  7. STARTUPINFO si;
  8. PROCESS_INFORMATION pi;
  9.  
  10. ZeroMemory( &si, sizeof(si) );
  11. si.cb = sizeof(si);
  12. ZeroMemory( &pi, sizeof(pi) );
  13.  
  14. if( argc != 2 )
  15. {
  16. printf("Usage: %s [cmdline]\n", argv[0]);
  17. return -1;
  18. }
  19.  
  20. // Start the child process.
  21. if( !CreateProcessA( NULL, // No module name (use command line)
  22. "notepad.exe",//argv[1], // Command line
  23. NULL, // Process handle not inheritable
  24. NULL, // Thread handle not inheritable
  25. FALSE, // Set handle inheritance to FALSE
  26. 0, // No creation flags
  27. NULL, // Use parent's environment block
  28. NULL, // Use parent's starting directory
  29. &si, // Pointer to STARTUPINFO structure
  30. &pi
  31. ) // Pointer to PROCESS_INFORMATION structure
  32. )
  33. {
  34. printf( "CreateProcess failed (%d).\n", GetLastError() );
  35. return -1;
  36. }
  37.  
  38. // Wait until child process exits.
  39. WaitForSingleObject( pi.hProcess, INFINITE );
  40.  
  41. // Close process and thread handles.
  42. CloseHandle( pi.hProcess );
  43. CloseHandle( pi.hThread );
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement