当前位置:编程学习 > VB >>

VB编程问题

VB中,按一个按钮就移动查找一个文件,如QQ.EXE,查找到文件位置后运行这个文件,要完整代码
追问:来自手机问问这么长?!能解释下吗?
答案:Private Declare Function SearchTreeForFile Lib "imagehlp.dll" (ByVal lpRoothPath As String, ByVal lpInputName As String, ByVal lpOutputName As String) As Long

Public 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 L_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
   Else
         sysFileFind = ""
   End If
   Exit Function
L_FILEFINDERROR:
   MsgBox "查找文件过程中遇到错误!", vbInformation, "查找文件错误"
   sysFileFind = Format(Err.Number) & " - " & Err.Description
End Function

Private Sub Command1_Click()
   On Error Resume Next
   Shell sysFileFind("C:\", "qq.exe"), vbNormalFocus

   End
End Sub

上一个:vb编程问题!
下一个:关于VB编程

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,