; ###########################################################################
.586 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include windows.inc
include kernel32.inc
szCopy PROTO :DWORD,:DWORD
szCatStr PROTO :DWORD,:DWORD
CheckPath PROTO :DWORD
.data
fcount dd 0 ;<-- globals
.code
; ###########################################################################
align 4
CountFiles proc szpath:dword,szfilter:dword,rec:dword
LOCAL hSearch :DWORD
LOCAL wfd :WIN32_FIND_DATA
LOCAL buffer[MAX_PATH] :byte
invoke szCopy, szpath, addr buffer
invoke szCatStr, addr buffer, szfilter
invoke FindFirstFile, addr buffer, addr wfd
mov hSearch, eax
.if eax != INVALID_HANDLE_VALUE
.while eax != 0
mov ax, word ptr wfd.cFileName
.if ax != 0002eh && ax != 02e2eh ; "." ".."
.if wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
sub fcount, 1
.if rec
invoke szCopy, szpath, addr buffer
invoke szCatStr, addr buffer, addr wfd.cFileName
invoke CheckPath, addr buffer
invoke CountFiles, addr buffer, szfilter, rec
.endif
.endif
add fcount, 1
.endif
invoke FindNextFile, hSearch, addr wfd
.endw
invoke FindClose, hSearch
.endif
mov eax, fcount
ret
CountFiles endp
; ###########################################################################
end
the code works correctly, until attempt to integrate it in the library, since I do not have access to the variable
to put it to zero, before calling it
how i fix it?
When you create the library module, IF the global is only used by that module, simple make a data section at the beginning of the module and use it that way.
If you want that global visible to other modules, declare it as a PUBLIC variable with syntax like,
PUBLIC YourVar
And in the module that want to use it,
EXTERNDEF YourVar :DWORD
all ok :U
thanx hutch-