hello, as it works GetLogicalDriveStrings,
I need an example.
thanks
Posted on 2002-10-21 22:05:17 by dagas
Read the documentation on MSDN and post the code you have done: we will help you to make it work if it has problems...
Posted on 2002-10-22 02:04:39 by JCP


.486
.MODEL FLAT, STDCALL
OPTION CASEMAP: NONE
INCLUDE \MASM32\INCLUDE\WINDOWS.INC
INCLUDE \MASM32\INCLUDE\KERNEL32.INC
INCLUDE \MASM32\INCLUDE\USER32.INC
INCLUDELIB \MASM32\LIB\KERNEL32.LIB
INCLUDELIB \MASM32\LIB\USER32.LIB

.DATA
FILE_MASK DB "*", 0
BACK DB "..", 0
TESTFILE DB "TEST.TXT", 0
BLA DB 13, 10

.DATA?
BUFFER DB 100 DUP ( ? )
W32FD WIN32_FIND_DATA < ? >
S_HANDLE DD ?
TESTHANDLE DD ?

.CODE
START: INVOKE _lcreat, ADDR TESTFILE, 0
MOV TESTHANDLE, EAX
CALL SCAN_DRIVES
INVOKE _lclose, TESTHANDLE
INVOKE ExitProcess, 0

SCAN_DRIVES:
INVOKE GetLogicalDriveStrings, 100, ADDR BUFFER
MOV EDI, OFFSET BUFFER
LOOP_: INVOKE GetDriveType, EDI ; - use this to search only on fixed
CMP EAX, DRIVE_FIXED ; drives or if you want to search only
JNZ BLAHHH ; a spezifed drive just set the current
; dir to the root and call SCAN_DIR not
; SCAN_DRIVES!!!
INVOKE SetCurrentDirectory, EDI
PUSH OFFSET BLAHHH

SCAN_DIR:
INVOKE FindFirstFile, ADDR FILE_MASK, ADDR W32FD
INC EAX
JZ _S_OUT
DEC EAX
MOV S_HANDLE, EAX
_S_SCAN:CMP W32FD.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY
JNZ NO_DIR
CMP BYTE PTR [ W32FD.cFileName ], "."
JZ NEXT_
INVOKE SetCurrentDirectory, ADDR W32FD.cFileName
PUSH S_HANDLE
CALL SCAN_DIR
POP S_HANDLE
JMP NEXT_
NO_DIR: INVOKE lstrlen, ADDR W32FD.cFileName
INVOKE _lwrite, TESTHANDLE, ADDR W32FD.cFileName, EAX
INVOKE _lwrite, TESTHANDLE, ADDR BLA, 2
NEXT_: INVOKE FindNextFile, S_HANDLE, ADDR W32FD
TEST EAX, EAX
JNZ _S_SCAN
INVOKE SetCurrentDirectory, ADDR BACK
INVOKE FindClose, S_HANDLE
_S_OUT: RET

BLAHHH: ADD EDI, 4
CMP BYTE PTR [ EDI ], 0
JNZ LOOP_
RET
END START

i wrote this years ago.... this was only a test, i wouldn't use this
way to scan through folders under normal circumstances. oh and the
structure is a little bit tricky... there are two procedures in one...
or something like this :)
Posted on 2002-10-22 04:58:14 by mob