API ShellExecute 功能说明及应用示例
时间:2009-08-04 09:50 来源:www.msaccessonline.com 作者:佚名 阅读:次
我们可以通过ShellExecute来执行“打开”,“查找”,“资源管理器”或“打印”操作
必要的声明:
' nShowCmd
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
' Error Code
Public Const ERROR_FILE_NOT_FOUND = 2
Public Const ERROR_PATH_NOT_FOUND = 3
Public Const ERROR_BAD_FORMAT = 11
Public Const SE_ERR_FNF = 2
Public Const SE_ERR_PNF = 3
Public Const SE_ERR_accessDENIED = 5
Public Const SE_ERR_OOM = 8
Public Const SE_ERR_SHARE = 26
Public Const SE_ERR_ASSOCINCOMPLETE = 27
Public Const SE_ERR_DDETIMEOUT = 28
Public Const SE_ERR_DDEFAIL = 29
Public Const SE_ERR_DDEBUSY = 30
Public Const SE_ERR_NOASSOC = 31
Public Const SE_ERR_DLLNOTFOUND = 32
Public 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
“打开”操作
ShellExecute Me.hwnd, "open", _
Text1.Text, _
vbNullString, vbNullString, _
SW_SHOWNORMAL
“查找”操作
ShellExecute Me.hwnd, "find", _
LocalDir, _
vbNullString, vbNullString, _
SW_SHOWNORMAL
“打印”操作
ShellExecute Me.hwnd, "print", _
Text1.Text, _
vbNullString, vbNullString, _
SW_SHOWNORMAL
“资源管理器”
ShellExecute Me.hwnd, "explore", _
LocalDir, _
vbNullString, vbNullString, _
SW_SHOWNORMAL
打开“我的文档”
ShellExecute Me.hwnd, _
"open", "explorer", _
vbNullString, vbNullString, _
SW_SHOWNORMAL
打开“我的电脑”
' 我的电脑
' HKEY_CLASSES_ROOT\CLSID' {20D04FE0-3AEA-1069-A2D8-08002B30309D}
ShellExecute Me.hwnd, "open", _
"explorer", _
"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", _
vbNullString, SW_SHOWNORMAL
打开“网上邻居”
' 网上邻居
' HKEY_CLASSES_ROOT\CLSID' {208D2C60-3AEA-1069-A2D7-08002B30309D}
ShellExecute Me.hwnd, "open", _
"explorer", _
"::{208D2C60-3AEA-1069-A2D7-08002B30309D}", _
vbNullString, SW_SHOWNORMAL
打开“回收站”
' 回收站
' HKEY_CLASSES_ROOT\CLSID' {645FF040-5081-101B-9F08-00AA002F954E}
ShellExecute Me.hwnd, "open", _
"explorer", _
"::{645FF040-5081-101B-9F08-00AA002F954E}", _
vbNullString, SW_SHOWNORMAL
必要的声明:
' nShowCmd
Public Const SW_HIDE = 0
Public Const SW_SHOWNORMAL = 1
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_MAXIMIZE = 3
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOW = 5
Public Const SW_MINIMIZE = 6
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_RESTORE = 9
' Error Code
Public Const ERROR_FILE_NOT_FOUND = 2
Public Const ERROR_PATH_NOT_FOUND = 3
Public Const ERROR_BAD_FORMAT = 11
Public Const SE_ERR_FNF = 2
Public Const SE_ERR_PNF = 3
Public Const SE_ERR_accessDENIED = 5
Public Const SE_ERR_OOM = 8
Public Const SE_ERR_SHARE = 26
Public Const SE_ERR_ASSOCINCOMPLETE = 27
Public Const SE_ERR_DDETIMEOUT = 28
Public Const SE_ERR_DDEFAIL = 29
Public Const SE_ERR_DDEBUSY = 30
Public Const SE_ERR_NOASSOC = 31
Public Const SE_ERR_DLLNOTFOUND = 32
Public 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
“打开”操作
ShellExecute Me.hwnd, "open", _
Text1.Text, _
vbNullString, vbNullString, _
SW_SHOWNORMAL
“查找”操作
ShellExecute Me.hwnd, "find", _
LocalDir, _
vbNullString, vbNullString, _
SW_SHOWNORMAL
“打印”操作
ShellExecute Me.hwnd, "print", _
Text1.Text, _
vbNullString, vbNullString, _
SW_SHOWNORMAL
“资源管理器”
ShellExecute Me.hwnd, "explore", _
LocalDir, _
vbNullString, vbNullString, _
SW_SHOWNORMAL
打开“我的文档”
ShellExecute Me.hwnd, _
"open", "explorer", _
vbNullString, vbNullString, _
SW_SHOWNORMAL
打开“我的电脑”
' 我的电脑
' HKEY_CLASSES_ROOT\CLSID' {20D04FE0-3AEA-1069-A2D8-08002B30309D}
ShellExecute Me.hwnd, "open", _
"explorer", _
"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", _
vbNullString, SW_SHOWNORMAL
打开“网上邻居”
' 网上邻居
' HKEY_CLASSES_ROOT\CLSID' {208D2C60-3AEA-1069-A2D7-08002B30309D}
ShellExecute Me.hwnd, "open", _
"explorer", _
"::{208D2C60-3AEA-1069-A2D7-08002B30309D}", _
vbNullString, SW_SHOWNORMAL
打开“回收站”
' 回收站
' HKEY_CLASSES_ROOT\CLSID' {645FF040-5081-101B-9F08-00AA002F954E}
ShellExecute Me.hwnd, "open", _
"explorer", _
"::{645FF040-5081-101B-9F08-00AA002F954E}", _
vbNullString, SW_SHOWNORMAL
(责任编辑:admin)
顶一下
(0)
0%
踩一下
(0)
0%
相关内容
- ·API函数详细解释
- ·Access从剪切版里复制和粘贴数据
- ·Access利用api实现打开/关闭光驱
- ·应用程序开机自动启动(注册表操作技巧
- ·Access VBA 判断网络是否连通的多种办
- ·什么是ADP,了解ADP的优缺点
- ·优秀产品大全--通用票据打印软件(新)
- ·[技巧分享]多条Shell语句执行导致判断
- ·在access中可以调用API函数GetFileInfo
- ·Access API集中营--增加临时使用的字体
- ·API ShellExecute 功能说明及应用示例
- ·在VB中使用API函数(什么是API? )
- ·API实现完美的图片出现效果(转)
- ·API 设置调整系统当前时间
- ·如何检测以及设置键盘状态
- ·不关闭当前数据库COPY当前数据库
最新内容
推荐内容