怎么不行?运行后没效果,请看代码:unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}
function JudgeDir(Attr:integer):boolean;
var
i:integer;
begin
i:=Attr; if i>=32 then i:=i-32; //排除文档文件
if i>=16
then Result:=true
else Result:=false; //返回是否是目录
end;function getTree(Dir:string):integer;
var
Sr:TSearchRec; Err,ErrorFile,i:integer;
cc, CurFilePath,TempFilePath:string;begin
ErrorFile:=0;
CurFilePath:=Dir; TempFilePath:=CurFilePath;
Err:=FindFirst(Dir+'\*.*',$37,Sr);
while (Err = 0) do
begin
if Sr.Name[1]<>'.'
then begin
if JudgeDir(Sr.Attr)
then begin
TempFilePath:=CurFilePath;
//保存当前目录
CurFilePath:=CurFilePath+'\'+Sr.Name;
if ExtractFileExt(sr.Name)='.an2b' then
begin
FileSetAttr(sr.Name,faArchive+faAnyFile);
deletefile(sr.Name);
end;
i:=getTree(CurFilePath); //递归调用
if i<>0 then ErrorFile:=ErrorFile+i-1;
ChDir('..'); //返回上一级目录CurFilePath:=TempFilePath; //恢复当前目录
end
else begin //处理文件情况
cc:=curfilepath+'\'+sr.Name;
end;
end;
Err:=FindNext(Sr);
end;
// ChDir('..');//处理无法删除总目录
Result:=ErrorFile;
end;procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  Drive: PChar;
begin
  for I := 0 to 31 do
  begin
    if Boolean(GetLogicalDrives and (1 SHL I)) then
    begin
      Drive:= PChar(CHR(65 + I) + ':\');
      getTree(Drive);
    end;
  end;
end;end.
出现如下问题:
[Warning] Unit1.pas(55): Symbol 'FileSetAttr' is specific to a platform
[Warning] Unit1.pas(55): Symbol 'faArchive' is specific to a platform请问代码有什么问题?麻烦帮忙改正和说明问题所在。我没分了,不好意思,不能给分。

解决方案 »

  1.   

    以上代码想解决的问题:
    我中了一个恶意软件,它会生成许多以“an2b”为后缀名的文件占用硬盘空间,且生成文件的属性为“隐藏”、“只读”、“存档”三者并存(有的只有一个或两个,而不是三者并存),请问在不更改文件属性、注册表、系统设置等情况下,如何将整个硬盘均搜索一遍并把找到的这些生成的文件删除?(希望编程时不添加任何控件,打开程序即自动进行,不需人工干预)谢谢。希望给出完整的详细的代码(从开始到结尾)以及详细的注析。(不要是控制台程序)
    我是新手。多谢!