麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > VBScript > 正文

vbs,hta中選擇文件夾對話框?qū)崿F(xiàn)代碼

2020-07-26 11:53:28
字體:
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:

on error resume next
SelectFolder
function SelectFolder()
Const MY_COMPUTER = &H11&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, "選擇文加夾:", OPTIONS, strPath)
If objFolder Is Nothing Then
msgbox "您沒有選擇任何有效目錄!"
End If
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
msgbox "您選擇的文件夾是:" & objPath
end function


但是這個(gè)代碼不能在hta里用,原因是權(quán)限不夠,不知道其它機(jī)子上能不能。
于是寫了個(gè)用vbs自帶函數(shù)和fso結(jié)合的文件夾選擇代碼,僅供參考
復(fù)制代碼 代碼如下:

<script language=vbscript>
dim spath
spath="Root"

function SFolder()
on error resume next
Dim fso, drv, f, fc, nf, s, i, p, r, d
i=3
if spath="Root" then
Set fso =CreateObject("Scripting.FileSystemObject")
Set drv =fso.Drives
s="輸入序號(hào)為進(jìn)入,序號(hào)+#為選中(c為取消)"+chr(13)+chr(10)
s=s+"1.根目錄"+chr(13)+chr(10)
s=s+"2.上層"+chr(13)+chr(10)
For Each a In drv
s=s+cstr(i)+"."+ a.Path+chr(13)+chr(10)
i=i+1
Next
GetD s
else
Set fso =CreateObject("Scripting.FileSystemObject")
if right(spath,1)<>"/" then
spath=spath+"/"
end if
Set fc =fso.GetFolder(spath).SubFolders
s="輸入序號(hào)為進(jìn)入,序號(hào)+#為選中(c為取消)"+chr(13)+chr(10)
s=s+"1.根目錄"+chr(13)+chr(10)
s=s+"2.上層"+chr(13)+chr(10)
for each nf in fc
s=s+cstr(i)+"."+nf+chr(13)+chr(10)
i=i+1
next
GetF s
end if
end function

function GetD(s)
on error resume next
p=inputbox(s,"","")
if p="c" then
exit function
end if
r=split(s,chr(13)+chr(10))
if right(p,1)="#" then
if left(p,len(p)-1)=1 then
msgbox "這是根目錄,不能選擇根目錄!"
GetD s
elseif left(p,len(p)-1)=2 then
msgbox "這是根目錄,不能選擇根目錄!"
GetD s
else
d=split(r(left(p,len(p)-1)),".")
msgbox "選擇:" & d(1)
Document.forms("ValidForm").FPath.Value=d(1)
spath="Root"
end if
else
if p=1 then
msgbox "已經(jīng)是根目錄!"
GetD s
elseif p=2 then
msgbox "已經(jīng)是最上層!"
GetD s
else
d=split(r(p),".")
spath=d(1)
'msgbox "進(jìn)入:" & d(1)
SFolder
end if
end if
end function

function GetF(s)
on error resume next
p=inputbox(s,"","")
if p="c" then
exit function
end if
r=split(s,chr(13)+chr(10))
if right(p,1)="#" then
if left(p,len(p)-1)=1 then
msgbox "這是根目錄,不能選擇根目錄!"
GetD s
elseif left(p,len(p)-1)=2 then
GetTheParent =CreateObject("Scripting.FileSystemObject").GetParentFolderName(spath)
msgbox "選擇:" & GetTheParent
Document.forms("ValidForm").FPath.Value=GetTheParent
else
d=split(r(left(p,len(p)-1)),".")
msgbox "選擇:" & d(1)
Document.forms("ValidForm").FPath.Value=d(1)
spath="Root"
end if
else
if p=1 then
spath="Root"
SFolder
elseif p=2 then
GetTheParent =CreateObject("Scripting.FileSystemObject").GetParentFolderName(spath)
if GetTheParent="" then
spath="Root"
'msgbox "進(jìn)入:根目錄"
else
spath=GetTheParent
'msgbox "進(jìn)入:" & GetTheParent
end if
SFolder
else
d=split(r(p),".")
spath=d(1)
'msgbox "進(jìn)入:" & d(1)
SFolder
end if
end if
end function
</script>
<form id="ValidForm" method="POST" action="--WEBBOT-SELF--">
<p><input type="text" name="FPath" size="50" onclick="PastePath"><input type="button" value="選擇文件夾" name="SelFolder" onclick="SFolder"></p>
</form>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 日日鲁夜夜视频热线播放 | 国产chinesehd精品91 | 黄网站免费入口 | 久久午夜国产 | 精品在线视频观看 | 成人在线观看免费爱爱 | 日本不卡中文字幕 | 欧美日韩在线视频一区 | 久久久久久99 | 免费国产视频大全入口 | 欧美日韩在线中文字幕 | 国产91片 | 在线播放免费视频 | 久久精品一二三区白丝高潮 | 国外成人在线视频 | 免费国产不卡午夜福在线 | 女教师~淫辱の动漫在线 | 黄色片免费视频 | lutube成人福利在线观看 | 色综合精品 | 久久国产精品久久久久久久久久 | 日韩精品a在线观看 | av不卡免费在线 | 片在线观看 | 羞羞答答www网站进入 | 国产做爰 | 性欧美极品xxxx欧美一区二区 | 一级大片一级一大片 | 日韩黄色一区 | 一本色道久久综合狠狠躁篇适合什么人看 | 国产免费片 | 欧美性生活久久久 | 怦然心动50免费完整版 | 国产精品久久久久影院老司 | 成人nv在线观看 | 亚洲午夜久久久精品一区二区三区 | 亚洲第一色片 | 国产欧美亚洲精品a | 国产在线看一区 | 久久精品视频亚洲 | 成人免费自拍视频 |