Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<iostream>
- #include<Windows.h>
- #include<fstream>
- using namespace std;
- int main()
- {
- STARTUPINFO siCreator;
- PROCESS_INFORMATION procInfoCreator;
- char* inputFileName = (char*)malloc(sizeof(char));
- char lpszComLineCreator[80] = "Creator.exe ";
- cout << "Input file name:";
- cin >> inputFileName;
- char *bufName = inputFileName;
- strcat(bufName, ".txt");
- strcat(lpszComLineCreator, inputFileName);
- ZeroMemory(&siCreator, sizeof(STARTUPINFO));
- siCreator.cb = sizeof(STARTUPINFO);
- if (!CreateProcess(NULL,lpszComLineCreator, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &siCreator, &procInfoCreator))
- {
- cout << "Process \"Creator\" isn't created." << endl;
- return 0;
- }
- cout << "Process is created." << endl;
- WaitForSingleObject(procInfoCreator.hProcess,INFINITE);
- ifstream fin(bufName, ios::binary | ios::in);
- if (!fin.is_open())
- {
- cout << "File isn't opened!" << endl;
- return 0;
- }
- CloseHandle(procInfoCreator.hThread);
- CloseHandle(procInfoCreator.hProcess);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement