手机
当前位置:查字典教程网 >脚本专栏 >vbs >Windows Script Host之用vbs实现[浏览文件夹]功能
Windows Script Host之用vbs实现[浏览文件夹]功能
摘要:'************************************************'File:Dialog.vbs(WSHs...

'************************************************

'File:Dialog.vbs(WSHsampleinVBScript)

'Author:(c)G.Born

'

'Usingtheshelldialogboxtoselectafolder

'************************************************

OptionExplicit

'Flagsfortheoptionsparameter

ConstBIF_returnonlyfsdirs=&H0001

ConstBIF_dontgobelowdomain=&H0002

ConstBIF_statustext=&H0004

ConstBIF_returnfsancestors=&H0008

ConstBIF_editbox=&H0010

ConstBIF_validate=&H0020

ConstBIF_browseforcomputer=&H1000

ConstBIF_browseforprinter=&H2000

ConstBIF_browseincludefiles=&H4000

Dimwsh,objDlg,objF

'GetApplicationobjectoftheWindowsshell.

SetobjDlg=WScript.CreateObject("Shell.Application")

'UsetheBrowseForFoldermethod.

'Forinstance:SetobjF=objDlg.BrowseForFolder_

'(&H0,"Selectthefoldertocopy",&H10,"C:Born")

SetobjF=objDlg.BrowseForFolder(&H0,_

"Selectthefoldertocopy",_

BIF_editbox+BIF_returnonlyfsdirs)

'Hereweusethefirstmethodtodetecttheresult.

IfIsValue(objF)Then

MsgBox"Selectedfolder:"&objF.Title

Else

MsgBox"Canceled"

EndIf

'HereweuseTypeNametodetecttheresult.

IfInStr(1,TypeName(objF),"Folder")>0Then

MsgBox"Selectedfolder:"&objF.Title

Else

MsgBox"Canceled"

EndIf

FunctionIsValue(obj)

'Checkwhetherthevaluehasbeenreturned.

Dimtmp

OnErrorResumeNext

tmp=""&obj

IfErr<>0Then

IsValue=False

Else

IsValue=True

EndIf

OnErrorGoTo0

EndFunction

'***End

【Windows Script Host之用vbs实现[浏览文件夹]功能】相关文章:

vbs实现只复制比目标文件更新的文件

用vbs实现定时运行web文件的方法

用vbs实现更改计算机的说明的代码

使用vbs下载文件的代码加强版

用vbs实现的简单的服务器文件备份办法压缩文件名自动按日期命名

vbs复制文件夹的实现代码

用vbs实现的确定共享文件夹的本地路径?

用vbs实现重新启动 Internet Explorer

用vbs实现配置静态 IP 地址

用VBS实现的批量gb2312转utf-8,支持拖动

精品推荐
分类导航