词条 | SearchTreeForFile |
释义 | SearchTreeForFileVB声明Declare 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 |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。