vb如何装载一个只知道文件名的外部程序
来源:百度知道 编辑:UC知道 时间:2024/05/27 06:23:47
bluescreen.exe 和你的程序在同一层文件夹还是在 EXE 所在文件夹的子文件夹里面?
如果是同一层,那么 Shell App.Path & "\bluescreen.exe", vbNormalFocus 即可,
而如果在子文件夹里面,那么:
Private Declare Function SearchTreeForFile Lib "imagehlp.dll" (ByVal lpRoothPath As String, ByVal lpInputName As String, ByVal lpOutputName As String) As Long
Private Sub Command1_Click()
Dim s As String
s = FastSearchFile(Left(App.Path, 3), "bluescreen.exe")
If s <> "" Then
MsgBox s
Shell s, vbNormalFocus
Else
MsgBox "没找到!"
End If
End Sub
Public Function FastSearchFile(ByVal szSearchPath As String, ByVal szSearchFileName As String) As String
On Error GoTo ToExit
Dim ret As Long
Dim szBuffer As String * 255
ret = SearchTreeForFile(szSearchPath, szSearchFileName, szBuffer)
If ret <> 0 Then
FastSearchFile = Left(szBuffer, InStr(szBu