News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

example for findfirst findnext with longfilenames

Started by johann, September 07, 2008, 03:44:43 PM

Previous topic - Next topic

johann

anyone i'm looking for an example findfirst + findnext with longfilenames

Tight_Coder_Ex

Unlike OpenFile dialog where you can specify long names, FindFirstFile will accept whatever name you pass to it with or without wildcards so long as it doesn't exceed MAX_PATH

Import_Ascii_Text
enter 150h, 0 ; Make stack frame large enough for locals and
push ebx ; WIN32_FIND_DATA structure
lea ebx, [ebp - 150h] ; EBX = WIN32_FIND_DATA
push ebx
push Search_Mask
call _FindFirstFileA@8
mov [ebp - 4], eax ; Save handle retured by function
inc eax ; -1 is returned if nothing is found
jz .Done ; Leave, there are no files in directory to evaluate

.ReadFile
call Open_Data ; Open the file names in EBX + 1CH
and eax, eax ; was opening sucessful
jz .01 ; Nope try next file

mov [ebp - 8], eax ; Save handle returned by callee

push dword [ebp - 8]
call _CloseHandle@4

.01
push ebx ; WIN32_FIND_DATA
push dword [ebp - 4] ; hFindFile handle
call _FindNextFileA@8
and eax, eax
jnz .ReadFile

push dword [ebp - 4]
call _FindClose@4 ; Close handle opened at begining of procedure
.Done
pop ebx
leave ; recover stack space
ret ; return to caller