I am using the example from here to restart an application:
Restart an application by itself
It works well. Until I want to take the parameter passed into the application and pass it along to the restart instance.
lstrcpy(tbuf, lpCmdLine);
lstrcat(tbuf, L"OSP_PID.EXE ");
lstrcat(tbuf, lpCmdLine);
wsprintf(buf, L"/C ping 127.0.0.1 -n 5 && \"%s \"" , tbuf);
ExecWin(L"cmd.exe", buf, TRUE);
PostMessage(hWnd, WM_CLOSE, 0, 0L);
buf== L"/C ping 127.0.0.1 -n 5 && \"C:\\VEC25WIN8\\DEBUG\\OSP_PID.EXE C:\\VEC25WIN8\\DEBUG\\ \""
//lstrcat(tbuf, lpCmdLine);
buf== L"/C ping 127.0.0.1 -n 5 && \"C:\\VEC25WIN8\\DEBUG\\OSP_PID.EXE \""
In the first example, this is what I am trying to accomplish. The ping works but then nothing.
The second example shows the passed argument removed. This works, the application starts up, but there is no argument being passed along.
The "buf==" is from the debug WATCH panel.
I don't see anything wrong with this. Please advise.
Boyd
static void ExecWin(LPTSTR acTaskname, LPTSTR acParameters, int nShow )
{ // everything is on the stack - reenterable
SHELLEXECUTEINFO execinfo;
ZeroMemory(&execinfo, sizeof(SHELLEXECUTEINFO));
execinfo.cbSize = sizeof(SHELLEXECUTEINFO);
execinfo.lpParameters = acParameters;
execinfo.lpFile = acTaskname;
execinfo.nShow = nShow;
if ((ShellExecuteEx(&execinfo)) && ((int)execinfo.hInstApp > 32))
{
return;
}
return;
}