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
|
void __fastcall TForm1::Checksum(AnsiString pmRep)
{
TSearchRec SearchRec;
int Attributes = 0;
AnsiString bcRep = "",
bcRepTemp = "",
bcFile = "",
bcExt = "";
Attributes |= faAnyFile;
bcRep = pmRep;
if(bcRep[bcRep.Length()] != '\\')
{
bcRep+= "\\"; // ajout du slash final si il n'y est pas
}
bcRepTemp = bcRep;
bcRep+= "*.*";
if(FindFirst(bcRep, Attributes, SearchRec) == 0) // on recherche TOUS les fichiers/dossiers
{
do
{
bcFile = SearchRec.Name; // on recupere le nom du fichier/dossier trouver
if(bcFile != "." && bcFile != "..") //on filtre les repertoires '.' et '..'
{
bcFile = bcRepTemp + SearchRec.Name;
bcExt = ExtractFileExt( bcFile ) ; // on recupere l'exstension du fichier
if(SearchRec.Attr != faDirectory)
{
if (Fabort==true)
return;
if ( LowerCase(bcExt) == ".exe") // on test si c'est un executable
{
AddInList( bcFile, MD5HashFile( bcFile ) ) ;
ValueListEditor1->Strings->Add(bcFile+" = "+MD5HashFile (bcFile ));
AfficherFichierActif(bcFile);
}
}
else
{
Checksum(bcFile); // si c'est un repertoire, on "scan" ce repertoire
}
}
}
while (FindNext(SearchRec) == 0); // jusqu'a ce qu'il n'y ai plus de fichiers
FindClose(SearchRec); // on ferme le TSearchRec
}
} |
Partager