首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

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

2012-06-23 
vb.net中如何以windows默认方式打开文件?各位:我在网上搜了一下:PrivateDeclareFunctionShellExecuteLibs

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")文件路径


就可以了

热点排行