1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| bool __fastcall test::runExternalExecutable(String sDSN, String sUsername, String sPassword, String sSetOrGroup, String sSelData, long worldId, String sResFilePrefix)
{
sExtPath = "C:\\Program Files\\test\\testexe";
String app = "test.exe";
String param = sDSN + " " + sUsername + " " + sPassword + " " + sSetOrGroup + " " + sSelData + " " + IntToStr(worldId) + " " + sResFilePrefix;
if(!(ShellExecute(NULL, "open", app.c_str(), param.c_str(), sExtPath.c_str(), SW_SHOW) > (HINSTANCE)32))
{
String info = "Cannot start '" + app + " " + param + "'";
Application->MessageBox(info.c_str(), "erreur", MB_OK);
}
return FileExists(sResFilePrefix + "_F");
//*** problème de l'approche ci-dessus : n'attend pas que que le programme soit terminé avant de continuer
/*HANDLE hProcess;
DWORD ProcessId;
DWORD exitCode;
sExtPath = "C:\\Program Files\\test\\testexe\\";
String app = "test.exe";
String param = sDSN + " " + sUsername + " " + sPassword + " " + sSetOrGroup + " " + sSelData + " " + IntToStr(worldId) + " " + sResFilePrefix;
String sCmd = sExtPath + app + " " + param;
ProcessId = system(sCmd.c_str());
if(ProcessId == 0)
Application->MessageBox("erreur", "logSQL", MB_OK);
else
{
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, false, ProcessId);
do
{
GetExitCodeProcess(hProcess, &exitCode);
Application->ProcessMessages();
}while(exitCode == STATUS_PENDING);
CloseHandle(hProcess);
}*/
return true;
} |
Partager