下面是VB中全部的代码
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String '这么定义
cAlternateFileName As String '这么定义
dwFileType As Long
dwCreatorType As Long
wFinderFlags As Integer
End Type
Private
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA"
(ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Private Sub Form_Load()
Dim lpFileName As String
lpFileName = String(256, Chr(0))
lpFileName = "c:\temp\32\p.exe"
Dim lpWin32FileData As WIN32_FIND_DATA
Dim re As Long
re = FindFirstFile(lpFileName, lpWin32FileData)
Text1.Text = re
End Sub
在c:\temp\32\中不放置p.exe的文件运行程序返回值为-1
我在c:\temp\32\中放值了一个叫p.exe的文件后运行程序出现内存访问错误(找到了一个文件.而没有进方存放那个名....)
我想肯定就是WIN32_FIND_DATA中的cFileName和cAlternateFileName没有存贮空间的原因吧??????
高手指点啊~~~~~~~~~~~~~~~~~~~~~~
[此贴子已经被作者于2007-10-23 11:35:12编辑过]