Windows Script Host之用vbs实现[浏览文件夹]功能
Windows Script Host之用vbs实现[浏览文件夹]功能
发布时间:2016-12-28 来源:查字典编辑
摘要:'************************************************'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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新vbs学习
热门vbs学习
脚本专栏子分类