How to wait for child process when CreateProcess creates 2 process viz. run32dll process which creates internally windows photo viewer Process

  • Thread starter Thread starter Vaibhaw Pratap Singh
  • Start date Start date
V

Vaibhaw Pratap Singh

Guest
I have created process using CreateProcess() to open image using windows photo viewer. Since windows photo viewer is not .exe, it run with run32dll.exe, hence creating 2 process. so run32 becomes the parent process and windows photo viewer is child process. Now I want to wait for child process to be created. How to do this...

I have shared the code snippet ...

STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));

CString appSt = L"rundll32 \"C:\\Program Files\\Windows Photo Viewer\\PhotoViewer.dll\" ImageView_Fullscreen D:\\\\Results\\1.png";

CreateProcess(NULL, // Name of program to execute
CT2W(appSt), // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
TRUE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi);

WaitForSingleObject(pi.hProcess, INFINITE); //its waiting for infinite time.

Continue reading...
 
Back
Top