利用兩種簡易方法實現直接打開一個文件
發表于:2007-07-14來源:作者:點擊數:
標簽:
作者:徐建波 代碼如下: 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 nS
作者:徐建波
代碼如下:
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
Const SW_SHOW = 5
Private Sub Command1_Click()
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Text1.Text = CommonDialog1.FileName
ShellExecute Me.hwnd, "open", CommonDialog1.FileName, "", "", SW_SHOW
'方法二
' Str1 = "start " & CommonDialog1.FileName
' Shell Str1
End If
End Sub
原文轉自:http://www.anti-gravitydesign.com