Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<iostream>
  3. #include<Windows.h>
  4. #include<fstream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.  
  11. STARTUPINFO siCreator;
  12. PROCESS_INFORMATION procInfoCreator;
  13. char* inputFileName = (char*)malloc(sizeof(char));
  14. char lpszComLineCreator[80] = "Creator.exe ";
  15.  
  16. cout << "Input file name:";
  17. cin >> inputFileName;
  18. char *bufName = inputFileName;
  19. strcat(bufName, ".txt");
  20. strcat(lpszComLineCreator, inputFileName);
  21.  
  22. ZeroMemory(&siCreator, sizeof(STARTUPINFO));
  23. siCreator.cb = sizeof(STARTUPINFO);
  24.  
  25. if (!CreateProcess(NULL,lpszComLineCreator, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &siCreator, &procInfoCreator))
  26. {
  27. cout << "Process \"Creator\" isn't created." << endl;
  28. return 0;
  29. }
  30.  
  31. cout << "Process is created." << endl;
  32.  
  33. WaitForSingleObject(procInfoCreator.hProcess,INFINITE);
  34.  
  35. ifstream fin(bufName, ios::binary | ios::in);
  36.  
  37. if (!fin.is_open())
  38. {
  39. cout << "File isn't opened!" << endl;
  40. return 0;
  41. }
  42.  
  43.  
  44. CloseHandle(procInfoCreator.hThread);
  45. CloseHandle(procInfoCreator.hProcess);
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement