Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \\Parent process(В 1 проекте)
- #include <stdio.h>
- #include <windows.h>
- #include <ctime>
- int main()
- {
- STARTUPINFO StartupInfo;
- PROCESS_INFORMATION ProcInfo;
- TCHAR TXT[] = TEXT("D:\\Visual Studio\\4\\lab 1\\Debug\\Child.exe");
- ZeroMemory(&StartupInfo, sizeof(StartupInfo));
- StartupInfo.cb = sizeof(StartupInfo);
- ZeroMemory(&ProcInfo, sizeof(ProcInfo));
- printf("Parent process was run.\n");
- time_t seconds = time(NULL);
- tm* timeinfo = localtime(&seconds);
- printf("Current Datetime:%s", asctime(timeinfo));
- Sleep(10000);
- if (!CreateProcess(TXT,
- NULL,
- NULL,
- NULL,
- FALSE,
- CREATE_NEW_CONSOLE,
- NULL,
- NULL,
- &StartupInfo,
- &ProcInfo)
- )
- printf("CreateProcess failed.\n");
- WaitForSingleObject(ProcInfo.hProcess, INFINITE);
- printf("End of child process.\n");
- Sleep(10000);
- CloseHandle(ProcInfo.hProcess);
- CloseHandle(ProcInfo.hThread);
- }
- \\Child process(2 проект)
- #include <windows.h>
- #include <stdio.h>
- #include <ctime>
- int main()
- {
- printf("Child process was run.\n");
- time_t seconds = time(NULL);
- tm* timeinfo = localtime(&seconds);
- printf("Current Datetime:%s", asctime(timeinfo));
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement