如题,利用API函数(ShellExecute)打开本机电脑文件夹及已注册类型的任何文件。
- 'API函数声明
- 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
- Sub open我的电脑()
- ShellExecute Application.hwnd, "open", "explorer", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 0, 1
- End Sub
- Sub open网上邻居()
- ShellExecute Application.hwnd, "open", "explorer", "::{208d2c60-3aea-1069-a2d7-08002b30309d}", 0, 1
- End Sub
- Sub open回收站()
- ShellExecute Application.hwnd, "open", "explorer", "::{645ff040-5081-101b-9f08-00aa002f954e}", 0, 1
- End Sub
- Sub open控制面板()
- ShellExecute Application.hwnd, "open", "explorer", "::{21ec2020-3aea-1069-a2dd-08002b30309d}", 0, 1
- End Sub
- Sub open我的文档()
- ShellExecute Application.hwnd, "open", "explorer", 0, 0, 1
- End Sub
- Sub open文件夹()
- ShellExecute Application.hwnd, "open", "C:\Program Files\Tencent\QQ\Bin", 0, 0, 1
- End Sub
- Sub open应用程序()
- ShellExecute Application.hwnd, "open", "C:\Program Files\Tencent\QQ\Bin\QQ.exe", 0, 0, 1
- End Sub
- Sub openExcelFile()
- ShellExecute Application.hwnd, "open", "C:\text.xls", 0, 0, 1
- End Sub
- Sub openTextFile()
- ShellExecute Application.hwnd, "open", "C:\text.txt", 0, 0, 1
- End Sub
- Sub open网页()
- ShellExecute Application.hwnd, "open", "http://club.excelhome.net", 0, 0, 1
- End Sub
复制代码
|