Last active
August 29, 2015 14:16
-
-
Save arn-ob/c1f7ddf17ca426792653 to your computer and use it in GitHub Desktop.
Create a Child process ....... (Run only codeBlock GNU GCC compiler )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<Windows.h> | |
int main(VOID){ | |
STARTUPINFO si; | |
PROCESS_INFORMATION pi; | |
// Allocate memory | |
ZeroMemory(&si, sizeof(si)); | |
si.cb = sizeof(si); | |
ZeroMemory(&pi, sizeof(pi)); | |
if (!CreateProcess(NULL, "mspaint.exe", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) | |
{ | |
fprintf(stderr, "Create Process Failed"); | |
return -1; | |
} | |
// parent will wait for the child to complete | |
WaitForSingleObject(pi.hProcess, INFINITE); | |
printf("Child Complete"); | |
// Close Handles | |
CloseHandle(pi.hProcess); | |
CloseHandle(pi.hProcess); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try allocating the memory manually. VC++ has some problems with memory allocation.