Advertisement
Guest User

es3

a guest
Apr 1st, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <stdio.h>
  3.  
  4. #define INPUT_MAX 256
  5.  
  6. int main(int argc, char** argv) {
  7.     if(argc > 1) {
  8.         for (int i = 1; i < argc; ++i)
  9.             printf("%s ", argv[i]);
  10.         return 0;
  11.     }
  12.  
  13.     char str[INPUT_MAX + 14];
  14.    
  15.     memcpy(str, ".\\es3_tut.exe ", 14);
  16.     fgets(str + 14, INPUT_MAX, stdin);
  17.  
  18.     puts(str);
  19.  
  20.     STARTUPINFO si;
  21.     PROCESS_INFORMATION pi;
  22.  
  23.     memset(&si, 0, sizeof(STARTUPINFO));
  24.     si.cb = sizeof(STARTUPINFO);
  25.  
  26.     BOOL is_created = CreateProcess(
  27.             ".\\es3_tut.exe",
  28.             str,
  29.             NULL,
  30.             NULL,
  31.             FALSE,
  32.             NORMAL_PRIORITY_CLASS,
  33.             NULL,
  34.             NULL,
  35.             &si,
  36.             &pi);
  37.  
  38.     if(!is_created) {
  39.         printf("il nuovo processo non può essere creato\n");
  40.         return 1;
  41.     }
  42.  
  43.     WaitForSingleObject(pi.hProcess, INFINITE);
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement