Using CreateProcess

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi
I am writing vc++ code in which i have to install an application and the program has to wait till the control returns from newly created process..My code is,
WCHAR cmd[] = L"D:\App.exe ";
/* STARTUPINFO si;<br/>
PROCESS_INFORMATION pi;<br/>
<br/>
ZeroMemory( &si, sizeof(si) );<br/>
si.cb = sizeof(si);<br/>
ZeroMemory( &pi, sizeof(pi) );<br/>
<br/>
<br/>
// Start the child process. <br/>
CreateProcess( NULL, // No module name (use command line)<br/>
cmd, // Command line<br/>
NULL, // Process handle not inheritable<br/>
NULL, // Thread handle not inheritable<br/>
FALSE, // Set handle inheritance to FALSE<br/>
0, // No creation flags<br/>
NULL, // Use parents environment block<br/>
NULL, // Use parents starting directory
<br/>
&si, // Pointer to STARTUPINFO structure<br/>
&pi ); // Pointer to PROCESS_INFORMATION structure<br/>
<br/>
<br/>
// Wait until child process exits.<br/>
WaitForSingleObject( pi.hProcess, INFINITE );<br/>
<br/>
// Close process and thread handles. <br/>
CloseHandle( pi.hProcess );<br/>
CloseHandle( pi.hThread );<br/>
<br/>


But the program simply exits without starting installation....any modification needed in this code??

Thanks. <hr class="sig Manigandasuresh

View the full article
 
Back
Top