Anyone know how to generate a files list on a directory?
LB_DIR?
Use FindFirst / FindNext
Bogdan, he is an experienced programmer who is brave enough to be lazy. So I offered him the lazy solution :bg
Quote from: jj2007 on December 28, 2010, 11:40:02 AM
Bogdan, he is an experienced programmer who is brave enough to be lazy. So I offered him the lazy solution :bg
Sorry, I did not really understand about recursive one, always wasting my stack :green
if you just want the files in the current directory - and not the subdirectories - you don't need a recursive routine
still - enumerating files is one of the best applications of recursion - and a good place to learn it :U
whether you use recursion or not, FindFirst and FindNext are the functions you need
they are pretty easy to use
one of the few things that is almost the same as old DOS programming :bg
Hi Onan,
Here is a quick example for you :
include ListFiles.inc
.data
FileName db '*.*',0
f1 db '%s',13,10,0
.data?
wfd WIN32_FIND_DATA <?>
hFind dd ?
buffer db MAX_PATH + 4 dup(?)
FName equ OFFSET wfd + WIN32_FIND_DATA.cFileName
.code
start:
invoke FindFirstFile,ADDR FileName,ADDR wfd
cmp eax,INVALID_HANDLE_VALUE
je _exit
mov hFind,eax
@@:
invoke wsprintf,ADDR buffer,ADDR f1,FName
invoke StdOut,ADDR buffer
invoke FindNextFile,hFind,ADDR wfd
test eax,eax
jnz @b
_exit:
invoke FindClose,hFind
invoke ExitProcess,0
END start
Thaks vortex :U