Can anyone see any obvious problem here?
It returns zero unless I execute the code at the bottom of the function, but I'd rather use the API call...
-------------
Scott
mailto:[email protected][email protected]</A>
It returns zero unless I execute the code at the bottom of the function, but I'd rather use the API call...
Code:
Function GetSizeOfFile(FileSpec As String) As Long Local l_zFileSpec As Asciiz * 255 Local l_hFindFile As Long Local lpFileSizeHigh As Long Local l_Result As Long Local finddata As WIN32_FIND_DATA l_zFileSpec = FileSpec finddata.dwFileAttributes = %FILE_ATTRIBUTE_DIRECTORY 'Or %FILE_ATTRIBUTE_NORMAL Or %FILE_ATTRIBUTE_ARCHIVE Or %FILE_ATTRIBUTE_READONLY l_hFindFile = FindFirstFile(l_zFileSpec, finddata) If l_hFindFile = %INVALID_HANDLE_VALUE Then Function = %INVALID_HANDLE_VALUE 'Check for it when pulling file size from main program otherwise wrong file size!! MsgBox "Invalid File Handle",%MB_ICONSTOP,CCS Exit Function End If l_Result = GetFileSize(ByVal l_hFindFile, lpFileSizeHigh) Function = lpFileSizeHigh FindClose l_hFindFile Exit Function 'Of course this works: l_hFindFile = FreeFile Open filespec For Input As #l_hFindFile Function = Lof(l_hFindFile) Close l_hFindFile End Function
Scott
mailto:[email protected][email protected]</A>
Comment