MyRemove how to use?

What you need to register at the beginning of the code, where uses?
And with sDir problem ...

  • one
    Why antivirus can not be used? And, as it seems to me, it is better to first look for a place where the virus itself sits. After all, if his executables are deleted from all folders, and he himself does not crash, then there will be little sense. - DelphiM0ZG
  • Because the company can not use fake programs without a license, so there are sources for this case? - Arsenty Suvorov
  • Try AVZ utility to scan or some other free scanner. I have no source code - I did not do such things. - DelphiM0ZG
  • 2
    My clever people went :) Any tricks began to come up with what would help the lab to do ... Give code, add comments ... conscience would have raped :) - Alex Kapustin
  • Sorry, just some of the procedures are not completely known to me ... If you don’t want, you don’t have to figure it out yourself - Arsenty Suvorov

1 answer 1

procedure TForm1.MyRemove(sdir: string); var iIndex: integer; // индСкс Π½Π°ΠΉΠ΄Π΅Π½Π½ΠΎΠ³ΠΎ Ρ„Π°ΠΉΠ»Π° SearchRec: TSearchRec; sFileName: string; dir: string; begin sDir:= sDir + '\*.*'; // устанавливаСм поиск любого // Ρ„Π°ΠΉΠ»Π° Π²Π½ΡƒΡ‚Ρ€ΠΈ ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΠΈ iIndex:= FindFirst(sDir, faAnyFile, SearchRec); // Π½Π°Ρ…ΠΎΠ΄ΠΈΠΌ ΠΏΠ΅Ρ€Π²Ρ‹ΠΉ Ρ„Π°ΠΉΠ» Π² Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΠΈ while iIndex = 0 do begin sFileName:= ExtractFileDir(sDir) + '\' + SearchRec.Name; // Π²Ρ‹Π±ΠΈΡ€Π°Π΅ΠΌ Π½Π°ΠΉΠ΄Π΅Π½Π½Ρ‹ΠΉ // Ρ„Π°ΠΉΠ» if SearchRec.Attr = faDirectory then // Ссли это дирСктория begin // смотрим Π΅Ρ‘ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ if (SearchRec.Name <> '') and // пропускаСм эти названия (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then MyRemove(sFileName); // ΠΎΡ‚ΠΊΡ€Ρ‹Π²Π°Π΅ΠΌ это Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΎΡ€ΠΈΡŽ для // прочСсывания end else // Ссли это Π½Π΅ ΠΏΠ°ΠΏΠΊΠ° begin if SearchRec.Attr <> faArchive then FileSetAttr(sFileName, faArchive); if Pos('.exe', SearchRec.Name) <> 0 then // смотрим Π½Π°Π·Π²Π°Π½ΠΈΠ΅ Ρ„Π°ΠΉΠ»Π° begin // Ссли это Π΅Ρ…Π΅ΡˆΠ½ΠΈΠΊ dir:= sDir; //Π½Π°Ρ…ΠΎΠ΄ΠΈΠΌ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΏΠ°ΠΏΠΊΠΈ Delete(dir, Pos('\*.*', dir), Length(dir)); // --//-- while Pos('\', Dir) <> 0 do // --//-- Delete(dir, 1, Pos('\', dir)); // --//-- // Если Π½Π°Π·Π²Π°Π½ΠΈΠ΅ Π΅Ρ…Π΅ΡˆΠ½ΠΈΠΊΠ° = названию ΠΏΠ°ΠΏΠΊΠΈ Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ ΠΎΠ½ Π»Π΅ΠΆΠΈΡ‚ if dir = Copy(SearchRec.Name, 1, Pos('.exe', SearchRec.Name) - 1) then // Ρ‚ΠΎ удаляСм Π΅Ρ…Π΅ΡˆΠ½ΠΈΠΊ DeleteFile(sFileName) end; end; // смотрим ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΡƒ Ρ„Π°ΠΉΠ» iIndex:= FindNext(SearchRec); end; // Π·Π°ΠΊΠ°Π½Ρ‡ΠΈΠ²Π°Π΅ΠΌ прочСсываниС FindClose(SearchRec); end; 
  • transfer to the procedure the directory in which to search. after which the procedure will look through all the folders in this directory and look for the file .exe, which will have the name = the name of the folder in which the file is located - tean
  • Molochina need to try out !!!! And can you comment on the code a little, otherwise I don’t understand everything iIndex: = FindNext (SearchRec) is that when the search is over? - Arsenty Suvorov
  • added comments - teanYCH
  • uses need something to add? - Arsenty Suvorov
  • I have problem IDs [Error] Unit1.pas (7): The declaration was expected, but the "sDir" identifier was found [Error] Unit1.pas (25): an undeclared identifier: 'MyRemove "[Error] Unit1.pas (32): undeclared id: 'sDir "[Error] Unit1.pas (46): undeclared id:' MyRemove" [Attention] Unit1.pas (51): "faArchive" The symbol is specific to the platform [Attention] Unit1.pas (52): " FileSetAttr "Symbol is platform specific [Attention] Unit1.pas (52):" faArchive "Symbol is platform specific [Error] Unit1.pas (11): Unsatisfied forward or external ad:" TForm1.FormCreate - Arsenty Suvorov