Bonjour à tous,
J'utilise dans mon programme la fonction CreateProcess() pour lancer une autre application.
Quand je lance cette application manuellement, je vois dans l'onglet Processus du Gestionnaire des tâches, le nom complet de mon application qui s'appelle EBICSMoteur.exe or quand je le lance depuis le CreateProcess(), le nom de mon application est tronqué en EBISCM~1.exe ou EBISCM~2.exe
Je souhaiterai, quand je lance mon application par la fonction CreateProcess(), le nom reste en entier.
Voici mon code :
function TFonctions.LanceComEBICS(DossierAppli: String): Byte;
var
StartInfo : TStartupInfo;
ProcInfo : TProcessInformation;
CreateOK : Boolean;
Commande : String;
NomUtil : String;
cExe : array [0..255] of Char;
sExe : String;
fnFile : TFileName;
ProcEbics : Dword;
Begin
NomUtil := '"Standard"';
fnFile := ExtractFilePath(Application.ExeName) + 'EBICSMoteur.exe';
FindExecutable(PChar(ExtractFileName(fnFile)), PChar(ExtractFilePath(fnFile)), cExe);
sExe := String(cExe);
FillChar(StartInfo,SizeOf(TStartupInfo), #0); // Mise à zéro de la structure StartInfo
//Seule la taille est renseignée, toutes les autres options laissées à zéro prendront les valeurs par défaut
ZeroMemory(@StartInfo, SizeOf(StartInfo));
StartInfo.cb := SizeOf(StartInfo);
StartInfo.dwFlags := STARTF_USESHOWWINDOW;
StartInfo.wShowWindow := SW_NORMAL;
FillChar(ProcInfo,SizeOf(TProcessInformation), #0);
Commande := '"' + fnfile + '" "' + DossierAppli + '" '+ NomUtil;
CreateOK := CreateProcess(PChar(sExe),
PChar(Commande),
nil,
nil,
False,
CREATE_NEW_CONSOLE + NORMAL_PRIORITY_CLASS + CREATE_DEFAULT_ERROR_MODE,
nil,
PChar(ExtractFilePath(fnFile)),
StartInfo,
ProcInfo);
if CreateOK then //CreateOK est à True si le process est bien créé.
begin
ProcEbics := ProcInfo.dwProcessId;
//Tant que mon EBICS tourne , on traite les messages pour ne pas figer l'application
repeat
Application.ProcessMessages;
EnumWindows(@EbicsAuPremierPlan, ProcEbics);
until WaitForSingleObject(ProcInfo.hProcess, 100) = WAIT_OBJECT_0 ;
try
CloseHandle(ProcInfo.hThread); //On Close le Thread
CloseHandle(ProcInfo.hProcess); //On Close le Process
except;
end;
Result := 0; //Ici, la télétrans a bien fonctionné. On met donc RESULT à 0.
end
else begin
//Si on a pas pu lancer le process de la télétrans.
Result := 13;
ShowMessage(SysErrorMessage(GetLastError));
end;
end;
Merci pour votre aide.
Cordialement.