当前位置: 移动技术网 > IT编程>脚本编程>VBScript > Windows Script Host之用vbs实现[浏览文件夹]功能

Windows Script Host之用vbs实现[浏览文件夹]功能

2017年12月12日  | 移动技术网IT编程  | 我要评论

安康有哪些旅游景点,傲运天禧,iko导轨

'************************************************
' 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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网