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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
LRESULT CProductionDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
CString sCleName,s;
UINT nIndex;
BOOL bResult=TRUE;
TCHAR szCle[MAX_CLE];
// TODO: Add your specialized code here and/or call the base class
// Lancement des exe utilisateur sur choix menu
switch(message)
{
case WM_SYSCOMMAND :
nIndex= LOWORD (wParam)-ID_EXE;
if(nIndex>0 && nIndex<=NB_EXE_MAX)
{
if(m_hExe[nIndex-1]!=NULL)
{
//Process touijours present
DWORD dwExitCode = 0;
GetExitCodeProcess(m_hExe[nIndex-1], &dwExitCode);
if(dwExitCode == STILL_ACTIVE) //process toujours présent ?
::SetForegroundWindow((HWND) m_hExe[nIndex-1]); //Premier plan
else
m_hExe[nIndex-1]=NULL;
}
// si l'exe n'existe pas on le lance
if(m_hExe[nIndex-1]==NULL)
{
sCleName.Format("%s%d",PATH_EXE_ENTETE,nIndex);
GetPrivateProfileString(SECTION_EXECUTABLES, sCleName, "", szCle, MAX_CLE, INIFILE);
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
if(CreateProcess(NULL,szCle,0,0,FALSE,
CREATE_DEFAULT_ERROR_MODE,0,0,
&siStartupInfo,&piProcessInfo) == FALSE)
{
// erreur
CString s;
s.Format("Erreur d'ouverture de l'utilitaire %s",szCle);
AfxMyMessageBox(s,MB_ICONERROR);
}
else
{
m_hExe[nIndex-1] = piProcessInfo.hProcess;
}
}
}
break; |
Partager