bonjour , j'utilise indy 10.5.5 sous delphi 2010

j'aimerais faire executer une ligne de commande par un server indy ,

j'ai codé un client server de base, j'arrive à transmettre du texte au serveur dans un memo que je récupere comme ça

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
text := Acontext.Connection.IOHandler.ReadLn();
          memo1.text := text;
apres j'ai trouvé sur la board la fonction ExecuteCommand qui fonctionne très bien ,

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
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
 
 
 function BuildDosCommandStr(Command:string):string;
begin
    result:='cmd /c "'+Command+'"';
end;
 
 
 
  function ExecuteCommande(Commande: String;Attente : Boolean = True): Boolean;
Var
  lpsaProcess,
  lpsaThread    : PSecurityAttributes;
  StartupInfo   : TStartupInfo;
  ProcessInfo   : TProcessInformation;
  AddrCmd       : Array [0..255] Of Char;
  ExitCode      : DWord;
begin
  FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
  with StartupInfo do
  begin
    cb          := SizeOf(TStartupInfo);
    dwFlags     := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
    wShowWindow := SW_HIDE;
  end;
 
  New(lpsaProcess);
  New(lpsaThread);
 
  lpsaProcess^.nLength              := SizeOf(lpsaProcess^);
  lpsaProcess^.lpSecurityDescriptor := Nil;
  lpsaProcess^.bInheritHandle       := True;
 
  lpsaThread^.nLength              := SizeOf(lpsaThread^);
  lpsaThread^.lpSecurityDescriptor := Nil;
  lpsaThread^.bInheritHandle       := True;
 
  StrPCopy(AddrCmd, Commande);
  Result := CreateProcess(nil, AddrCmd, lpsaProcess, lpsaThread, False,
                          STARTF_FORCEONFEEDBACK, nil, nil, StartupInfo, ProcessInfo);
  if not Result then Result:=(GetLastError>10000);
  Dispose(lpsaProcess);
  Dispose(lpsaThread);
  if Result then
  begin
    while Attente do
    begin
      // Solution d'attente 1
      Sleep(500);
      GetExitCodeProcess(ProcessInfo.hProcess, ExitCode);
      if ExitCode<>STILL_ACTIVE then break;
 
      // Solution d'attente 2
      // WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
 
    end;
    CloseHandle(ProcessInfo.hThread);
    CloseHandle(ProcessInfo.hProcess);
  end;
end;
je peux l'appeler sur ma variable text , et si c'est une commande cohérente syntaxiquement , elle s'exécute ,

mais ,

comment je peux faire pour faire la différence entre du texte et les lignes de com à exécuter , en fait je voudrais garder text pour du texte et une autre variable com pour ce qui doit etre exécuté ,

c'est un autre thread que je dois créer ?? c'est pas bien clair pour moi encore