Kann
asked on
Enumerate files and folders in NTFS
How to enumerate files and folders in Windows XP (NTFS) on a very low level (no FindFirst or NTQueryFile). Perhaps the Win32API DeviceIoControl function with a FSCTL_ const?
Thanks for your hints & help!
Kann
Thanks for your hints & help!
Kann
Is this OK? ;)
procedure FindFilesAndDirs(Directory : string; var DestList : TStringList);
var
sr : TSearchRec;
dirs : array of string;
n : integer;
s : string;
begin
Directory := StringReplace(Directory,'/ ','\',[rfR eplaceAll] );
if Directory[length(Directory )] = '\' then SetLength(Directory, length(Directory) - 1);
SetLength(dirs, 1);
dirs[0] := Directory;
while Length(dirs) > 0 do begin
if FindFirst(format('%s\*.*', [dirs[0]]) ,faAnyFile ,sr) = 0 then while FindNext(sr) = 0 do begin
s := format('%s\%s',[dirs[0], sr.Name]);
if FileExists(s) then begin
DestList.Add(s);
end else if sr.Name <> '..' then begin
SetLength(dirs,length(dirs )+1);
dirs[high(dirs)] := s;
end;
end;
for n := low(dirs) to high(dirs) - 1 do dirs[n] := dirs[n+1];
SetLength(dirs,length(dirs ) - 1);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
list : TStringList;
begin
list := TStringList.Create;
FindFilesAndDirs('C:\SomeD ir',list);
ListBox1.Items := list;
list.Free;
end;
procedure FindFilesAndDirs(Directory
var
sr : TSearchRec;
dirs : array of string;
n : integer;
s : string;
begin
Directory := StringReplace(Directory,'/
if Directory[length(Directory
SetLength(dirs, 1);
dirs[0] := Directory;
while Length(dirs) > 0 do begin
if FindFirst(format('%s\*.*',
s := format('%s\%s',[dirs[0], sr.Name]);
if FileExists(s) then begin
DestList.Add(s);
end else if sr.Name <> '..' then begin
SetLength(dirs,length(dirs
dirs[high(dirs)] := s;
end;
end;
for n := low(dirs) to high(dirs) - 1 do dirs[n] := dirs[n+1];
SetLength(dirs,length(dirs
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
list : TStringList;
begin
list := TStringList.Create;
FindFilesAndDirs('C:\SomeD
ListBox1.Items := list;
list.Free;
end;
I believe he stated "no FindFirst"
<smile>
Shane
<smile>
Shane
ou.. Didn't see that 'no' ;) sorry..
ASKER
shaneholmes, this source (VWIN32) can only be used with Win9x. I need information about NTFS (Windows XP). Any hints?
ASKER
I found a solution, but there is no source code or documentation available :-(
"NtFsControlFile : FSCTL_READ_MFT_RECORD makes it possible to very efficiently determine what files are on a NTFS volume and where their clusters are located, but its use requires detailed knowledge of undocumented NTFS on-disk data structures, "
I think, this question is to difficult to find a solution...
"NtFsControlFile : FSCTL_READ_MFT_RECORD makes it possible to very efficiently determine what files are on a NTFS volume and where their clusters are located, but its use requires detailed knowledge of undocumented NTFS on-disk data structures, "
I think, this question is to difficult to find a solution...
ASKER
If you have an answer you get also 500 points here (together 1000 points)
https://www.experts-exchange.com/questions/20946139/1000-Points-Enumerate-files-and-folders-in-NTFS.html
https://www.experts-exchange.com/questions/20946139/1000-Points-Enumerate-files-and-folders-in-NTFS.html
if u want low level, use assembly. Here is the link. It uses interrupts to get the files. Is this what you want?
http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH13/CH13-6.html#HEADING6-176
http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH13/CH13-6.html#HEADING6-176
ASKER
Hi fawndull, low level applied to NTFS programming technics, not to the programming language ;-) (The link descripted an articel about MSDOS, Sep. 1996.)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use the VWIN32 unit from
http://www.efg2.com/Lab/Library/Delphi/IO/DejanMaksimovicAlfa32.zip.
SHane