Bonsoir tout le monde, voila 4h que j'essaye de résoudre un problème qui est le suivant :

voici la méthode que j'appelle, avant son exécution, this->cmd est de valeur : "rsync -rtv /cygdrive/e/guillaume/ --port=3874 /cygdrive/q/guillaume/ > text.txt" lors de l'appel de la méthode, tout fonctionne bien hormis le fait qu'il ne tiens pas du tout en compte le caractère ">" pour charger le résultat de ma commande dans le fichier "text.txt". Cette commande marche parfaitement en mode commande de windows. J'ai essayé tout ce que je connaissait. le type attendu par CreateProcess est un char*, ce que je lui ai donné de toutes les façons possible. Ca fonctionne bien sous delphi avec la commande :

CreateProcess(nil,PChar(programmest), nil, nil, False,
CREATE_DEFAULT_ERROR_MODE + NORMAL_PRIORITY_CLASS, nil, nil, myStartupInfo, myProcessInfo); (programmest étant un String)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
int Commande::Executer(){
    Form1->Label1->Caption = this->cmd;
    DWORD codeSortie;
    int valeurRetour = 0;
    STARTUPINFO infoDemarrage;
    PROCESS_INFORMATION infoProcessus;
    memset(&infoDemarrage, 0, sizeof(TStartupInfo));
    memset(&infoProcessus, 0, sizeof(TProcessInformation));
    infoDemarrage.cb = sizeof(TStartupInfo);
    infoDemarrage.dwFlags = STARTF_USESHOWWINDOW;
    infoDemarrage.lpTitle = this->cmd.c_str();
    if (invisible)
        infoDemarrage.wShowWindow = SW_HIDE;
    else
        infoDemarrage.wShowWindow = SW_SHOWNORMAL;
    if(CreateProcess(NULL, this->cmd.c_str(), NULL, NULL, 0, CREATE_DEFAULT_ERROR_MODE
                     ,NULL, NULL, &infoDemarrage, &infoProcessus)){
        GetExitCodeProcess(&infoProcessus.hProcess, &codeSortie);
        while(WaitForSingleObject(infoProcessus.hProcess, 0)==WAIT_TIMEOUT){
            Application->ProcessMessages();
            GetExitCodeProcess(&infoProcessus.hProcess, &codeSortie);
        }
    }
    else
        valeurRetour = GetLastError();
    CloseHandle(infoProcessus.hProcess);
    CloseHandle(infoProcessus.hThread);
    return valeurRetour;
}
Merci d'avance à mon sauveur.

borgirz.