can anyine help me make a piece of code that will traverse the directory structure of win9x, right now i am using FindFirstFile and FindNextFile to find the files, but it will only get those that are in the current directory, and i want to find all files in lower/higher directories.

thanks
Posted on 2001-07-23 12:57:06 by SubHuman
Afternoon, SubHuman.

If you wish to traverse the entire directory structure, use 'C:\*' as the string for the 'FindFirstFile' function.:alright:

Source: Current Platform SDK:
To examine files in a root directory, use something like "C:\*" and step through the directory with FindNextFile.


'FindNextFile' finds the info on the next 'file' or 'subdirectory', so this will allow you to step through every file and subdirectory from the root directory.

If you wish to traverse more than one drive (e.g. 'D:\*', E:\*', etc) then you could use the 'GetLogicalDriveStrings' function to receive a root directory string of all available drives.;)

Cheers,
Scronty
Posted on 2001-07-23 17:30:55 by Scronty
this outputs only the directorys but you can change this
easy (just cut cmp ,FILE_ATTRIBUTE_DIRECTORY)...


.DATA
path db "c:\",300 dup (0)
poffset dd 3

FileName db "result.txt",0

FileHandle dd 0
SearchHandle dd 0
shit 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)


.CODE
start:

get_tree:
add poffset,offset path
push 0
push 0
find_dir:
mov eax,poffset
mov byte ptr ,"*"
mov byte ptr ,0

push offset W32FINDDATA
push offset path
call FindFirstFile

cmp eax,INVALID_HANDLE_VALUE
jz exit
mov SearchHandle,eax

loop_: cmp ,FILE_ATTRIBUTE_DIRECTORY
jnz no_dir
mov eax,offset cFileName
cmp byte ptr ,"."
jz no_dir

push SearchHandle
push poffset

push offset cFileName
push poffset
call lstrcpy

push offset cFileName
call lstrlen

add poffset,eax

mov eax,poffset
mov byte ptr ,"\"
mov byte ptr ,0
inc poffset

mov eax,poffset
mov word ptr ,0D0Ah
mov byte ptr ,0


invoke MessageBox,0,addr path,addr FileName,0

mov eax,poffset
mov byte ptr ,0

jmp find_dir
no_dir:

push offset W32FINDDATA
push SearchHandle
call FindNextFile

cmp eax,0
jnz loop_

pop poffset
pop SearchHandle
cmp poffset,0
jz quit
jmp loop_
quit:

push SearchHandle
call FindClose
exit:
ret
Posted on 2001-07-23 19:06:52 by Unregistered
thanks for your assistance

actually i just thought of something: is there an API call or something that will tell me what letters ate associated with hard disks, i think sometimes D: and E: can be HDDs, if the thing is partitioned
Posted on 2001-07-23 20:37:20 by SubHuman
Afternoon, SubHuman.

Source: Current Platform SDK:
'GetLogicalDrives':
The GetLogicalDrives function retrieves a bitmask representing the currently available disk drives.

If the function succeeds, the return value is a bitmask representing the currently available disk drives. Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on.

'GetLogicalDriveStrings':
The GetLogicalDriveStrings function fills a buffer with strings that specify valid drives in the system.


So! Use 'GetLogicalDrives' to find out which drives are available. and use 'GetLogicalDriveStrings' to get the strings for all available drives.:alright:

Cheers,
Scronty
Posted on 2001-07-23 21:12:11 by Scronty