vb打开外部文件
我想用VB制一个可以打开"*.txt","*.jpg","*.doc"等的文件(就如同在win界面中双击运行它一样的效果),但用shell只能打开"*.exe"。各位大虾...
我想用VB制一个可以打开"*.txt","*.jpg","*.doc"等的文件(就如同在win界面中双击运行它一样的效果),但用shell只能打开"*.exe"。各位大虾能帮我解决吗?
展开
1个回答
展开全部
可以用这个代码:
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 Label1_Click()
Call ShellExecute(Me.hwnd, "Open", Me.Label1.Caption, "", App.Path, 1)
End Sub
Me.Label1.Caption=什么就可以打开什么
例如:Me.Label1.Caption="c:\"
Me.Label1.Caption="http://www.hlgnet.com"
Me.Label1.Caption="mailto:yinlimin@sina.com"
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 Label1_Click()
Call ShellExecute(Me.hwnd, "Open", Me.Label1.Caption, "", App.Path, 1)
End Sub
Me.Label1.Caption=什么就可以打开什么
例如:Me.Label1.Caption="c:\"
Me.Label1.Caption="http://www.hlgnet.com"
Me.Label1.Caption="mailto:yinlimin@sina.com"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询