| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 
 | void __fastcall TForm1::FormCreate(TObject *Sender)
{
Memo1->Clear();
ShellExecute(0,"","cmd.exe"," /c Tasklist >1.txt /FO CSV  /FI \"USERNAME ne AUTORITE NT\SYSTEM\" /FI \"STATUS eq running\"  ",NULL, SW_SHOWNORMAL );
Sleep(2000);
TStringList *fichier = new TStringList();
fichier->LoadFromFile( "1.txt" ) ;
TStringList *ligne ;
  for( int i=1; i< fichier->Count; i++ )
      // 1 car la 1ere ligne contient le nom des colonnes
     {ligne = new TStringList() ;
      ligne->Text = StringReplace(fichier->Strings[i], ',' , "\n", TReplaceFlags()<< rfReplaceAll );
        for(int j=0; j < ligne->Count; j++)
        {  if ( j%5==0 )
           // 5 car "Nom de l'image","PID","Nom de la session","Numro de session","Utilisation mmoire"  Comme 5 colonnes
            {Memo1->Lines->Add(  StringReplace(ligne->Strings[j], '"' , "", TReplaceFlags()<< rfReplaceAll ) ) ;
             }
        } delete ligne    ; }   delete fichier ;
 
} | 
Partager