手机
当前位置:查字典教程网 >脚本专栏 >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类实现css按钮的代码

用vbs实现的输入助手附使用方法

vbs实现的汉字转拼音的函数

用vbscript实现将脚本的输出复制到剪贴板

vbs复制文件夹的实现代码

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

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

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

vbscript Registry 注册表操作实现代码(读写删除)

精品推荐
分类导航