我撰寫了以下的程式碼,但不知為何讀取不到資料
Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, lpOverlapped As Long) As Long
Const OFS_MAXPATHNAME = 128
Const OF_READ = &H0
Private Type OFSTRUCT
cBytes As Byte
fFixedDisk As Byte
nErrCode As Integer
Reserved1 As Integer
Reserved2 As Integer
szPathName(OFS_MAXPATHNAME) As Byte
End Type
Private Sub Command1_Click()
Dim OpenFileHandle As Long
Dim b As Long
Dim Length As String
Dim lpReOpenBuff As OFSTRUCT
OpenFileHandle = OpenFile("D:\no.txt", lpReOpenBuff, OF_READ)
b = ReadFile(OpenFileHandle, Length, 4, 4, 0&)
Text1.Text = LENGTH
End Sub
如無意外的話,我在OPENFILE那句裡已經取得有關的FILE的HANDLE,但為何在READFILE的LENGTH裡一點東西也沒有??
另外我想知道READFILE裡的"lpNumberOfBytesRead"是甚麼意思??我見了書說那個是
"真正讀取的資料長度"
,讀問這個和
"nNumberOfBytesToRead
"又甚麼分別