Enhanced version of the filesize function from the Masm32 library :
.386
.model flat,stdcall
option casemap:none
include filesize.inc
.code
filesize PROC lpszFileName:DWORD
LOCAL wfd:WIN32_FIND_DATA
invoke FindFirstFile,lpszFileName,ADDR wfd
cmp eax,INVALID_HANDLE_VALUE
jz fsEnd
invoke FindClose,eax
mov eax,wfd.nFileSizeLow
fsEnd:
ret
filesize ENDP
END
GetFileAttributesEx is simpler, but have an own features.
EDIT: function name fixed.
Also using FindFirstFileEx with FindExInfoBasic, if short name isn't needed.
A FindFirstFile is just a wrap function to FindFirstFileEx.
GetFileAttributesEx fails with "C:/pagefile.sys" with sharing error,
FindFirstFile not.
Hi Timo,
Thanks. Here is WIN32_FILE_ATTRIBUTE_DATA structure :
typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
} WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA;