![]() |
|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
||||
|
||||
![]() Помогите плз!
Надо осуществить поиск файла с заполнением прогрессбара. Пробовал вот так: Код:
function GetFileCount(Dir: string):Int64; var fs: TSearchRec; files:Int64; begin files:=0; if FindFirst(Dir+'\*.*', faAnyFile - faVolumeID, fs) = 0 then repeat if fs.Attr=faDirectory then Inc(files, GetFileCount(dir+'\'+fs.Name)); inc(files); until FindNext(fs) <> 0; FindClose(fs); result:=files; end; function OnFind(s:string):Boolean; begin ShowMessage(s); end; function FullDirectoryFind(StartDir: string; FindName:string; b:Byte): Boolean; var SR: TSearchRec; I: Integer; i1:Int64; begin ShowMessage(StartDir+' '+inttostr(GetFileCount(StartDir))); if b=1 then begin Form1.ProgressBar1.Max:=GetFileCount(StartDir); Form1.ProgressBar1.Position:=0; end; // ShowMessage('1'); //ShowMessage(IntToStr(Form1.ProgressBar1.max)); Result := False; StartDir := IncludeTrailingBackslash(StartDir); if not DirectoryExists(StartDir) then Exit; I := FindFirst(StartDir + '*', faAnyFile, SR); try while I = 0 do begin if (SR.Name <> '') and (SR.Name <> '.') and (SR.Name <> '..') then begin if SR.Attr = faDirectory then begin if SR.Name=FindName then OnFind(AddStr(StartDir, SR.Name)); FullDirectoryFind(StartDir+sr.Name, FindName, 0); end else begin if SR.Name=FindName then OnFind(AddStr(StartDir, SR.Name)) else Result := True; end; I := FindNext(SR); Form1.ProgressBar1.Position:=Form1.ProgressBar1.Position+1; end; end; finally SysUtils.FindClose(SR); end; if b=1 then Form1.ProgressBar1.Position:=0; end; ![]() Помогите пожалуйтса! Жизнь - игра. Сюжет тупой, зато графика офигенная |