Solved

Enumerate files and folders in NTFS

Posted on 2004-04-06
11
1,161 Views
Last Modified: 2010-04-16
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
0
Comment
Question by:Kann
  • 4
  • 2
  • 2
  • +2
11 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10767170
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 10769228
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,'/','\',[rfReplaceAll]);
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:\SomeDir',list);
ListBox1.Items := list;
list.Free;
end;
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10769264
I believe he stated "no FindFirst"

<smile>

Shane
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:ZhaawZ
ID: 10769452
ou.. Didn't see that 'no' ;) sorry..
0
 

Author Comment

by:Kann
ID: 10772396
shaneholmes, this source (VWIN32) can only be used with Win9x. I need information about NTFS (Windows XP). Any hints?
0
 

Author Comment

by:Kann
ID: 10772687
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...
0
 

Author Comment

by:Kann
ID: 10772730
If you have an answer you get also 500 points here (together 1000 points)
http://experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20946139.html
0
 
LVL 1

Expert Comment

by:fawndull
ID: 10779192
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
0
 

Author Comment

by:Kann
ID: 10782213
Hi fawndull, low level applied to NTFS programming technics, not to the programming language ;-) (The link descripted an articel about MSDOS, Sep. 1996.)
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11075745
Closed, 500 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Multiple image collision 13 90
How to define IfThen functions in one common unit? 4 64
Multi-layered image in FireMonkey 9 68
How to make Sign in, using Clientdataset? 1 34
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question