Windows Script Host之用vbs实现[浏览文件夹]功能
2007-07-27 17:15
946 查看
'************************************************
' File:Dialog.vbs (WSH sample in VBScript)
' Author:(c) G. Born
'
' Using the shell dialog box to select a folder
'************************************************
Option Explicit
' Flags for the options parameter
Const BIF_returnonlyfsdirs = &H0001
Const BIF_dontgobelowdomain= &H0002
Const BIF_statustext = &H0004
Const BIF_returnfsancestors= &H0008
Const BIF_editbox= &H0010
Const BIF_validate = &H0020
Const BIF_browseforcomputer= &H1000
Const BIF_browseforprinter = &H2000
Const BIF_browseincludefiles = &H4000
Dim wsh, objDlg, objF
' Get Application object of the Windows shell.
Set objDlg = WScript.CreateObject("Shell.Application")
' Use the BrowseForFolder method.
' For instance: Set objF = objDlg.BrowseForFolder _
' (&H0, "Select the folder to copy", &H10, "C:\Born")
Set objF = objDlg.BrowseForFolder (&H0, _
"Select the folder to copy", _
BIF_editbox + BIF_returnonlyfsdirs)
' Here we use the first method to detect the result.
If IsValue(objF) Then
MsgBox "Selected folder: " & objF.Title
Else
MsgBox "Canceled"
End If
' Here we use TypeName to detect the result.
If InStr(1, TypeName(objF), "Folder") > 0 Then
MsgBox "Selected folder: " & objF.Title
Else
MsgBox "Canceled"
End If
Function IsValue(obj)
' Check whether the value has been returned.
Dim tmp
On Error Resume Next
tmp = " " & obj
If Err <> 0 Then
IsValue = False
Else
IsValue = True
End If
On Error GoTo 0
End Function
'*** End
' File:Dialog.vbs (WSH sample in VBScript)
' Author:(c) G. Born
'
' Using the shell dialog box to select a folder
'************************************************
Option Explicit
' Flags for the options parameter
Const BIF_returnonlyfsdirs = &H0001
Const BIF_dontgobelowdomain= &H0002
Const BIF_statustext = &H0004
Const BIF_returnfsancestors= &H0008
Const BIF_editbox= &H0010
Const BIF_validate = &H0020
Const BIF_browseforcomputer= &H1000
Const BIF_browseforprinter = &H2000
Const BIF_browseincludefiles = &H4000
Dim wsh, objDlg, objF
' Get Application object of the Windows shell.
Set objDlg = WScript.CreateObject("Shell.Application")
' Use the BrowseForFolder method.
' For instance: Set objF = objDlg.BrowseForFolder _
' (&H0, "Select the folder to copy", &H10, "C:\Born")
Set objF = objDlg.BrowseForFolder (&H0, _
"Select the folder to copy", _
BIF_editbox + BIF_returnonlyfsdirs)
' Here we use the first method to detect the result.
If IsValue(objF) Then
MsgBox "Selected folder: " & objF.Title
Else
MsgBox "Canceled"
End If
' Here we use TypeName to detect the result.
If InStr(1, TypeName(objF), "Folder") > 0 Then
MsgBox "Selected folder: " & objF.Title
Else
MsgBox "Canceled"
End If
Function IsValue(obj)
' Check whether the value has been returned.
Dim tmp
On Error Resume Next
tmp = " " & obj
If Err <> 0 Then
IsValue = False
Else
IsValue = True
End If
On Error GoTo 0
End Function
'*** End
您可能感兴趣的文章:
相关文章推荐
- 在MFC中实现“浏览文件夹”功能
- 用vbs实现在启动 Windows 资源管理器时打开特定文件夹
- 实现浏览文件夹功能
- VMare中安装“功能增强工具”,实现CentOS5.5与win7host共享文件夹的创建
- 实现浏览文件夹功能
- 在win32中实现浏览文件夹功能与删除文件功能
- 实现浏览文件夹功能
- 【Vegas改编】用C#实现浏览文件夹功能
- 在MFC中实现“浏览文件夹”功能
- 如何用VC60实现类似windows搜索文件的功能,针对文件夹中包含的文件名进行模糊查
- VMare中安装“功能增强工具”,实现CentOS5.5与win7host共享文件夹的创建
- Windows查找文件夹下所有文件-C实现
- Windows的WinPcap编程实现ARP欺骗的基本功能的源码
- MFC实现打开、保存文件对话框和浏览文件夹对话框
- 最简单方法:windows平台下python安装opencv,即实现import cv2功能
- windows资源管理器多标签打开 windows文件夹多标签浏览 浏览器tab页面一样浏览文件夹 clover win8 win10 报错 无响应问题怎么解决 clover卡死 clover怎么换皮肤
- Webdriver实现下载功能,屏蔽掉windows弹出的对话框,FireFox下设置浏览器的属性,两种实现方式:
- C#实现的WINDOWS登录功能示例
- 使用cookies实现浏览历史记录功能
- vbs 实现文件夹拷贝--采用堆栈不递归