B
Benjamin Lukner
Hi!
I need some help getting GetFileInformationByHandle to work...
I don't know why, but I'm still getting an empty result.
I tried to use the BY_HANDLE_FILE_INFORMATION structure and also a byte
array having the same size. The byte array works fine for FindFirstFile,
but GetFileInformationByHandle always returns '0'.
Perhaps somebody's got a hint for me:
'[DECLARES]
Private Structure FILETIME
Dim dwLowDateTime As Int32
Dim dwHighDateTime As Int32
End Structure
Private Structure BY_HANDLE_FILE_INFORMATION
Dim dwFileAttributes As Int32
Dim ftCreationTime As FILETIME
Dim ftLastAccessTime As FILETIME
Dim ftLastWriteTime As FILETIME
Dim dwVolumeSerialNumber As Int32
Dim nFileSizeHigh As Int32
Dim nFileSizeLow As Int32
Dim nNumberOfLinks As Int32
Dim nFileIndexHigh As Int32
Dim nFileIndexLow As Int32
Dim dwOID As Int32
End Structure
Private Declare Function GetFileInformationByHandle Lib "Coredll"
Alias "GetFileInformationByHandle" ( _
ByVal hFile As Int32, _
ByVal lpFileInformation() As Byte _
) As Int32
'Private Declare Function GetFileInformationByHandle Lib "Coredll"
Alias "GetFileInformationByHandle" ( _
' ByVal hFile As Int32, _
' ByVal lpFileInformation As
BY_HANDLE_FILE_INFORMATION _
' ) As Int32
Private Declare Function FindFirstFile Lib "Coredll" Alias
"FindFirstFileW" ( _
ByVal lpFileName As String, _
ByVal lpFindFileData() As Byte _
) As Int32
'[FUNCTION]
Public Sub GetSize()
Dim hFile As Int32 = INVALID_HANDLE_VALUE
Dim oInfo As BY_HANDLE_FILE_INFORMATION
Dim oData As WIN32_FIND_DATA
Dim yData() As Byte
Dim yInfo(55) As Byte
Dim lReturn As Int32
' Creating byte array from STRUCT
yData = WIN32_FIND_DATA__TO__BYTE(New WIN32_FIND_DATA)
hFile = FindFirstFile("\Application\r*", yData)
oData = BYTE__TO__WIN32_FIND_DATA(yData)
If hFile <> INVALID_HANDLE_VALUE Then
MsgBox(oData.cfileName)
lReturn = GetFileInformationByHandle(hFile, yInfo) ' RETURNS '0'
If lReturn <> 0 Then
MsgBox(BitConverter.ToInt32(yInfo, 36).ToString)
End If
FindClose(hFile)
End If
End Sub
Kind regards,
Benjamin Lukner
trinomix GmbH
I need some help getting GetFileInformationByHandle to work...
I don't know why, but I'm still getting an empty result.
I tried to use the BY_HANDLE_FILE_INFORMATION structure and also a byte
array having the same size. The byte array works fine for FindFirstFile,
but GetFileInformationByHandle always returns '0'.
Perhaps somebody's got a hint for me:
'[DECLARES]
Private Structure FILETIME
Dim dwLowDateTime As Int32
Dim dwHighDateTime As Int32
End Structure
Private Structure BY_HANDLE_FILE_INFORMATION
Dim dwFileAttributes As Int32
Dim ftCreationTime As FILETIME
Dim ftLastAccessTime As FILETIME
Dim ftLastWriteTime As FILETIME
Dim dwVolumeSerialNumber As Int32
Dim nFileSizeHigh As Int32
Dim nFileSizeLow As Int32
Dim nNumberOfLinks As Int32
Dim nFileIndexHigh As Int32
Dim nFileIndexLow As Int32
Dim dwOID As Int32
End Structure
Private Declare Function GetFileInformationByHandle Lib "Coredll"
Alias "GetFileInformationByHandle" ( _
ByVal hFile As Int32, _
ByVal lpFileInformation() As Byte _
) As Int32
'Private Declare Function GetFileInformationByHandle Lib "Coredll"
Alias "GetFileInformationByHandle" ( _
' ByVal hFile As Int32, _
' ByVal lpFileInformation As
BY_HANDLE_FILE_INFORMATION _
' ) As Int32
Private Declare Function FindFirstFile Lib "Coredll" Alias
"FindFirstFileW" ( _
ByVal lpFileName As String, _
ByVal lpFindFileData() As Byte _
) As Int32
'[FUNCTION]
Public Sub GetSize()
Dim hFile As Int32 = INVALID_HANDLE_VALUE
Dim oInfo As BY_HANDLE_FILE_INFORMATION
Dim oData As WIN32_FIND_DATA
Dim yData() As Byte
Dim yInfo(55) As Byte
Dim lReturn As Int32
' Creating byte array from STRUCT
yData = WIN32_FIND_DATA__TO__BYTE(New WIN32_FIND_DATA)
hFile = FindFirstFile("\Application\r*", yData)
oData = BYTE__TO__WIN32_FIND_DATA(yData)
If hFile <> INVALID_HANDLE_VALUE Then
MsgBox(oData.cfileName)
lReturn = GetFileInformationByHandle(hFile, yInfo) ' RETURNS '0'
If lReturn <> 0 Then
MsgBox(BitConverter.ToInt32(yInfo, 36).ToString)
End If
FindClose(hFile)
End If
End Sub
Kind regards,
Benjamin Lukner
trinomix GmbH