;*********************D A T A**************************************************

;.data
;path db "c:\*.*",300 dup (0) ;--- enter directory to search here ,also you can search for files you like......*.txt ,*.exe , test.* and so on
;FileHandle dd 0
;W32FINDDATA dd 0
;dd 0
;dd 0
;dd 0
;dd 0
;dd 0
;dd 0
;nFileSizeHigh dd 0
;nFileSizeLow dd 0
;dwReserved0 dd 0
;dwReserved1 dd 0
;cFileName db MAX_PATH dup (0)
;cAlternate db 14 dup (0)
;
;
; call GET_DIR
; to list all files from a directory to a listbox anywhere in your code
; cooked in a hurry by Max
;**********************C O D E*************************************************
GET_DIR PROC
call FindFirstFile,offset path , offset W32FINDDATA ;--- call to find first file in offset path = c:\windows\*.*
cmp eax,INVALID_HANDLE_VALUE ;---- when error
jz exit ;--- jump to exit
mov FileHandle,eax ;-- insert the handle in FileHandle
loop_again :
cmp [W32FINDDATA],FILE_ATTRIBUTE_DIRECTORY ;-- check if found is a directory
jnz File_Found ;-- if not whe found a file...lets jump to File_Found
jmp No_File ;-- you can insert here stuff to get the dirname and insert it in another listbox or take it as string for next dir check - i jump to No_File
File_Found:
mov eax,offset cFileName ;-- fill eax with cFilename
.if eax>3 ;-- insert only if lenght is more then 3 - so whe dont insert "." + ".." or stuff like this
call SendDlgItemMessageA,hwnd_,500,LB_ADDSTRING,0,offset cFileName ;-- send cFilename to listbox
.endif
No_File:
call FindNextFile,FileHandle,offset W32FINDDATA ;-- check next file in FileHandle
cmp eax,0 ;-- check if eax is 0
jnz loop_again ;- if not there are more files to show...lets do a loop and jump to begin
call FindClose ,FileHandle ;-- if 0 then close search
exit:
ret ;-- and get back to call
GET_DIR ENDP
;***********************************************************************
Posted on 2001-12-20 03:49:51 by Max