使用默认程序打开文件
程序如下:
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()
′检查文件是否存在
′Filenm为一文本框的名字,在此输入待打开的文件名
If Dir(Filenm)=″″ Then
Call MsgBox(″此文件不存在!″,vbExclamation)
Exit Sub
End If
′使用默认程序打开文件
Call ShellExecute(hwnd,″Open″,Filenm,″″,App.Path,1)
End Sub
Private Sub Command2_Click()
′用默认浏览器浏览主页
Call ShellExecute(hwnd,″Open″,″http:∥coolknight.yeah.net″,″″,App.Path,1)
End Sub
Private Sub Command3_Click()
′用默认浏览器发送邮件
Call ShellExecute(hwnd,″Open″,″mailto:coolknight@263.net″,″″,App.Path,1)
End Sub