![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Не могу найти скрытые файлы [D7, WinXP]
Sicilla © (2005-01-30 18:13:00)Добрый день! есть такой код:
procedure Tform1.get_files(path, mask: string);
var
sr: TSearchRec;
FileAttrs: integer;
begin
FileAttrs := faReadOnly + faHidden + faSysFile + faArchive + faDirectory;
if FindFirst(path+'\'+mask, FileAttrs, sr) = 0 then
begin
repeat
if (SR.Name <>'.') and (SR.Name <>'..') then
begin
if SR.Attr > 16 then
begin
inc(find_files);
memo1.Lines.Add(inttostr(find_files) + ' ' + path+'\'+sr.Name + ' Size:' + inttostr(sr.Size));
end;
if sr.Attr = 16 then
begin
memo1.Lines.Add('Каталог ' + path+'\'+sr.Name);
get_files(path+'\'+sr.Name,'*.*');
end;
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
Label2.Caption := inttostr(find_files);
end;
Но он никак не хочет находить скрытые файлы. Как мне их поймать?
Fay (2005-01-30 20:15:00) [1]Вот так. Обрати внимание : здесь cPath включает, как завещал ExtactFilePath 8)
procedure TForm1.GetFiles(cPath, cMask : string);
var
fh : THandle;
fd : _WIN32_FIND_DATAA;
fn : string;
sz : LARGE_INTEGER;
begin
fh := FindFirstFile(PChar(cPath + cMask), fd);
if fh = INVALID_HANDLE_VALUE then Exit;
Memo1.Lines.BeginUpdate;
try
repeat
fn := Trim(fd.cFileName);
if (fd.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) <> 0 then
begin
if (fn <> '.') and (fn <> '..') then
begin
Memo1.Lines.Add('Каталог ' + cPath + fn);
GetFiles(cPath + fn + '\', '*.*');
end;
end
else
begin
sz.HighPart := fd.nFileSizeHigh;
sz.LowPart := fd.nFileSizeLow;
Inc(Files_Find);
Memo1.Lines.Add(IntToStr(Files_Find) + ' ' + cPath + fn + ' Size:' + IntToStr(sz.QuadPart));
end;
until not FindNextFile(fh, fd);
finally
Windows.FindClose(fh);
Memo1.Lines.EndUpdate;
end;
Label2.Caption := IntToStr(Files_Find);
end;