利用两种简易方法实现直接打开一个文件
【打印文章】
作者:徐建波
代码如下:
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
代码如下:
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
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )
【编程爱好者论坛】