读书人

vb.net中怎么以windows默认方式打开文

发布时间: 2012-06-23 14:52:43 作者: rapoo

vb.net中如何以windows默认方式打开文件?
各位:

我在网上搜了一下:
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()
Call ShellExecute(me.hwnd, "open ", "c:\windows\hh.exe ", vbNullString, vbNullString, &H0)

End Sub

用以上方式提示:错误1“hwnd”不是“Customer_Ord_SpaV2.Form1”的成员

于是改成:
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 Const SW_SHOWNORMAL = 1

Private Sub main()
ShellExecute 0, " ", "a.xls ", " ", "c:\ ", SW_SHOWNORMAL
End Sub
运行过程中报错:无法在 DLL“shell32.dll ”中找到名为“ShellExecuteA ”的入口点。

怎么解决啊?
求各位大侠指点!

[解决办法]
System.Diagnostics.Process.Start("C:\xx.mdb")文件路径


就可以了

读书人网 >VB Dotnet

热点推荐