I have a C++ app that launches another one with CreateProcess(). I fill the STARTUPINFO data with GetStartupInfo() before. Here is the code:
STARTUPINFOA si;
PROCESS_INFORMATION pi;
GetStartupInfoA( &si );
cout << si.dwFlags << endl;
cout << si.hStdError << endl;
cout << si.hStdInput << endl;
cout << si.hStdOutput << endl;
I use Win7/x64, SP1, VS2005, ICC 9.1 (Intel)
When I start the app from CubicExplorer it returns:
dwFlags = 1
hStdError = 0xffffffffffffffff
hStdInput = 0xffffffffffffffff
hStdOutput = 0xffffffffffffffff
(…and the second app I’m starting with CreateProcess using this STARTUPINFO works.)
When I start the app from the standard Windows Explorer it returns:
dwFlags = 1025 (0x401)
hStdError = 0x0000000000000000
hStdInput = 0x0000000000000000
hStdOutput = 0x0000000000010001
(… and CreateProcess fails with the error ACCESS_DENIED.)
My question: since the only difference is that the application is launched from a different folder explorer (Windows Explorer vs Cubic Explorer) what can produce these different info?
The
STARTUPINFOrecord you receive comes from theCreateProcesscall that started your program. Two different and completely independent programs calledCreateProcess, and they evidently chose to populate theSTARTUPINFOrecord differently. Nothing remarkable about that.Incidentally, unless
dwFlagsincludesSTARTF_USESTDHANDLES, it’s meaningless to read thehStdXfields.I recommend not simply forwarding your own startup parameters to the next program. Instead, explicitly populate exactly the startup fields you need for the next program. That wy, you know what you’re getting.