比如:
api定义如下:
Private Declare Function ReadFile Lib "KERNEL32" (ByVal hFile As Long, _
lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, _
lpNumberOfBytesRead As Long, ByVal lpOverlapped As Long) _
As Long
我的自定义结构是
Public Type AUTO
AutoID As String
AutoLicenseCode As String
AutoLicenseColor As String
AutoTypeID As String
OilTypeID As String
end type
读代码:
Private Sub readRecArray(Fname As String, anArray() As REC)
Dim fHandle As Long
Dim fSuccess As Long
Dim sTest As String
Dim lBytesRead As Long
Dim BytesToRead As Long '取数据大小
BytesToRead = (UBound(anArray) + 1) * LenB(anArray(0))
'取 Fname 的句柄
fHandle = CreateFile(Fname, GENERIC_WRITE Or GENERIC_READ, _
0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
'CreateFile 失败的话返回 INVALID_HANDLE_VALUE
If fHandle <> INVALID_HANDLE_VALUE Then
fSuccess = ReadFile(fHandle, anArray(LBound(anArray)), _
BytesToRead, lBytesRead, 0)
'ReadFile 成功后返回一个非 0 值
'关闭文件
fSuccess = CloseHandle(fHandle)
End If
End Sub
当运行到
fSuccess = ReadFile(fHandle, anArray(LBound(anArray)), _
BytesToRead, lBytesRead, 0)
时就出错了
如何读出来啊
注意:我读出数据后是放到数组里的,难道是api里的any类型的问题...该如何是好啊我
急,搞定即结帐
api定义如下:
Private Declare Function ReadFile Lib "KERNEL32" (ByVal hFile As Long, _
lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, _
lpNumberOfBytesRead As Long, ByVal lpOverlapped As Long) _
As Long
我的自定义结构是
Public Type AUTO
AutoID As String
AutoLicenseCode As String
AutoLicenseColor As String
AutoTypeID As String
OilTypeID As String
end type
读代码:
Private Sub readRecArray(Fname As String, anArray() As REC)
Dim fHandle As Long
Dim fSuccess As Long
Dim sTest As String
Dim lBytesRead As Long
Dim BytesToRead As Long '取数据大小
BytesToRead = (UBound(anArray) + 1) * LenB(anArray(0))
'取 Fname 的句柄
fHandle = CreateFile(Fname, GENERIC_WRITE Or GENERIC_READ, _
0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
'CreateFile 失败的话返回 INVALID_HANDLE_VALUE
If fHandle <> INVALID_HANDLE_VALUE Then
fSuccess = ReadFile(fHandle, anArray(LBound(anArray)), _
BytesToRead, lBytesRead, 0)
'ReadFile 成功后返回一个非 0 值
'关闭文件
fSuccess = CloseHandle(fHandle)
End If
End Sub
当运行到
fSuccess = ReadFile(fHandle, anArray(LBound(anArray)), _
BytesToRead, lBytesRead, 0)
时就出错了
如何读出来啊
注意:我读出数据后是放到数组里的,难道是api里的any类型的问题...该如何是好啊我
急,搞定即结帐
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货