SearchTreeForFile,VB系統中一種函式,該函式在imagehlp.dll動態程式庫中。
基本介紹
- 外文名:SearchTreeForFile
- 屬於:VB系統
- 性質:函式
- 存在:imagehlp.dll動態程式庫中。
VB聲明,說明,返回值,參考表,示例,
VB聲明
Public Declare Function SearchTreeForFile Lib "imagehlp.dll" (ByVal lpRoothPath As String, ByVal lpInputName As String, ByVal lpOutputName As String) As Long
該函式在imagehlp.dll動態程式庫中
說明
尋找檔案完整路徑
返回值
Long型,如果不存在該檔案返回值為0
參考表
lpRoothPath 查找的磁碟路徑 即根目錄
lpInputName 查找的檔案名稱字
lpOutputName 輸出路徑緩衝區
示例
用於查找F盤中是否存在1.txt這個檔案。
Private Declare Function SearchTreeForFile Lib "imagehlp.dll" _
(ByVal lpRoothPath As String, ByVal lpInputName As String, _
ByVal lpOutputName As String) As Long
Private Function sysFileFind(ByVal WhichRootPath As String, ByVal WhichFileName As String) As String
Dim iNull As Integer
Dim lResult As Long
Dim sBuffer As String
On Error GoTo FileFindError
sBuffer = String$(1024, 0)
lResult = SearchTreeForFile(WhichRootPath, WhichFileName, sBuffer)
If lResult Then
iNull = InStr(sBuffer, vbNullChar)
If Not iNull Then
sBuffer = Left$(sBuffer, iNull - 1)
End If
sysFileFind = sBuffer
MsgBox sysFileFind, vbOKOnly, "提示"
Else
MsgBox "F盤中不存在1.txt檔案", vbOKOnly, "提示"
End If
Unload Me
Exit Function
FileFindError:
MsgBox "查找檔案過程中遇到錯誤!", vbInformation, "查找檔案錯誤"
Unload Me
End Function
Private Sub Form_Load()
sysFileFind "F:\", "1.txt"
End Sub