FindFirst/FindNext is slow. I see program like Defraggler can gather this list quickly. What Windows API they use ?
Howto quickly gather file list with path and size information?
611 Views Asked by randadinata AtThere are 2 best solutions below

You are saying "FindFirst/FindNext" is slow. I think in terms of execution, _findfirst(), _findnext(), _findclose() #include <io.h> is as fast as it gets.
If you need very long path names, you need to use the Windows API version.
The Windows API is FindFirstFile(), FindNextFile(), and FindClose(), and the header file is #include <windows.h>.
The documentation for the Windows API tells you how to prepend "\?\" to the directory strings and get the maximum possible path length.
If you need more information than the C Library functions give you, then you need to use the Windows API FindFirstFileEx(), FindNextFileEx(), FindClose().
I have to refer you to the documentation for the details.
Simplest, C Library, _findfirst(): https://msdn.microsoft.com/en-us/library/zyzxfzac.aspx
More Info returned, Maximum path lengths, Windows API FindFirstFile(): https://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx
Maximum Info returned, Maximum path lengths, Windows API FindFirstFileEx(): https://msdn.microsoft.com/en-us/library/windows/desktop/aa364419(v=vs.85).aspx
If the links are no longer valid, you probably can search something like "C Language _findfirst()", etc.
Not sure about Defraggler; however you could use powershell
If you are on a windows xp system you will have to download and install it
with powershell you can preform a simple query
for example:
in powershell this will put all of the file names in the windows directory into an array called $foo
you can then go further and take the array and pipe it into a file
Example output:
For more info on powershell checkout
http://technet.microsoft.com/en-us/library/bb978526.aspx