i asked this question a couple days ago
https://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20720592.html
i wanted to execute an external exe and wait for its completion before my program continues
i used this code:
DWORD ExecuteAndWaitForCompletio
n ( LPSTR pszCmd)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
BOOL bRes;
DWORD dwCode = 0;
MSG msg;
ZeroMemory ( &si, sizeof ( STARTUPINFO));
si.cb = sizeof ( STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
bRes = CreateProcess ( NULL,
pszCmd,
NULL,
NULL,
TRUE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi
);
while ( WAIT_OBJECT_0 != MsgWaitForMultipleObjects ( 1,
&pi.hProcess,
FALSE,
INFINITE,
QS_ALLINPUT
)
)
{
while ( PeekMessage ( &msg, NULL, 0, 0, PM_REMOVE))
{
DispatchMessage ( &msg);
}
}
GetExitCodeProcess ( pi.hProcess, &dwCode);
CloseHandle ( pi.hProcess);
CloseHandle ( pi.hThread);
return ( dwCode);
}
it works just fine. however, in another version of this same program (where I used .NET - which is why I'm redoing in MFC) i was able to launch the external EXE and then rename the EXE file to .tmp so the user would have a hard time finding it
i don't want the user to find this exe because it is an unencrypted thing that I don't want them to detach from my wrapper application
how can i modify the above code to rename the EXE to FILENAME.tmp after the EXE begins executing?
thanks,
Justin Kohlhepp
New Standard