ShellExecute使用方法
ShellExecute能打开东西很多,打开外部程序、网页、文件夹、EMAIL、我的文档、我的电脑、回收站等等。一切与系统关联的东西都可以用它来打开,谓之全能打手也不过份。

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

'lpOperation可用参数:openprintfindexploreedit

'nShowCmd参数 窗口模式类型声明
Private Const SW_HIDE = 0
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOWNOACTIVATE = 4
Private Const SW_SHOW = 5
Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_RESTORE = 9


'激活相关程序,发送EMAIL
ShellExecute Me.hwnd, vbNullString, "mailto:ewang11@21cn", vbNullString, "C:\", SW_SHOWNORMAL

'打开应用程序
'打开计算器
ShellExecute Me.hwnd, "open", "", "", "", SW_SHOW
'最大化打开记事本
'ShellExecute Me.hwnd, "open", "", "", "", SW_SHOWMAXIMIZED
'打开ACCESS文件
'ShellExecute Me.hwnd, "open", "db34.mdb", "", "CurrentProject.Path", SW_SHOW

'OPEN的方式打开文件夹
'ShellExecute Me.hwnd, "open", "", "", "D:\Bam", SW_SHOWNORMAL
'explore的方式打开文件夹
'ShellExecute Me.hwnd, "explore", vbNullString, vbNullString, "D:\Bam", SW_SHOWNORMAL
'find的方式打开文件夹
ShellExecute Me.hwnd, "find", "", "", "D:\Bam", SW_SHOWNORMAL

'打开我的文档
ShellExecute Me.hwnd, "explore", vbNullString, vbNullString, vbNullString, SW_SHOWN
ORMAL

'打开我的电脑
ShellExecute Me.hwnd, "open", _
        "explorer", _
        "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", _
        vbNullString, SW_SHOWNORMAL

'打开网上邻居
ShellExecute Me.hwnd, "open", _
        "explorer", _
        "::{208D2C60-3AEA-1069-A2D7-08002B30309D}", _
        vbNullString, SW_SHOWNORMAL

'打开回收站
ShellExecute Me.hwnd, "open", _
        "explorer", _
        "::{645FF040-5081-101B-9F08-00AA002F954E}", _
        vbNullString, SW_SHOWNORMALnotepad++

'打开网页
ShellExecute Me.hwnd, "open", "www.office-cn/vvb/index.php", "", "", SW_SHOWMAXIMIZED

'打印文件
ShellExecute Me.hwnd, "print", "5.txt", vbNullString, vbNullString, SW_SHOWNORMAL

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。