vb如何使用超链接打开外部程序

来源:百度知道 编辑:UC知道 时间:2024/06/03 08:32:07

Private Sub Form_Click()
Shell "calc.exe", 1
End Sub

Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
Dim Sfile As String
CommonDialog1.ShowOpen
Sfile = CommonDialog1.FileName
ShellExecute Me.hWnd, "Open", Sfile, "", "", vbNormalFocus
End Sub
需要添加commondialog控件,在工程--部件--microsoft common dialog control里,这样你可以打开任意文件

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Form_Cl