1/2 - I'm not sure it matters. It's good practice to zero things out for these types of api's anyway.
3 - I wouldn't make any assumptions about member positions.
Here's a utility function I use:
Code:
bool run(const wchar_t *cmd, PROCESS_INFORMATION *pi/*=0*/, bool bHide/*=true*/,
const wchar_t *cmd_line/*=0*/)
{
// CreateProcess() needs a non-const string for 2nd param
const wchar_t *p1 = 0;
wchar_t p2[MAX_PATH * 2] = {0};
if (cmd_line)
{
p1 = cmd;
lstrcpyW(p2, cmd_line);
}//if
else
{
p1 = 0;
lstrcpyW(p2, cmd);
}//else
PROCESS_INFORMATION ProcInfo = {0};
STARTUPINFOW si = {0};
si.cb = sizeof(si);
if (bHide)
{
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
}//if
BOOL bSuccess;
bSuccess = CreateProcessW(p1, p2, 0, 0, FALSE, 0, 0, 0, &si, &ProcInfo);
if (!bSuccess)
{
LogMessage(L"CreateProcess(%ls %ls) failed, le = %u",
cmd, cmd_line ? cmd_line : L"", GetLastError());
return false;
}//if
else
{
LogMessage(L"Run(%ls %ls)", cmd, cmd_line ? cmd_line : L"");
}//else
if (pi)
{
// caller is responsible for closing handles
*pi = ProcInfo;
}//if
else
{
CloseHandle(ProcInfo.hThread);
CloseHandle(ProcInfo.hProcess);
}//else
return true;
}//run
gg