AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > VB编程

利用两种简易方法实现直接打开一个文件

51自学网 http://www.wanshiok.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
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

 

 

 
上一篇:用VB实现象Windows记事本的一些功能  下一篇:利用INI文件给程序创建动态菜单