VBS 如何使BrowseForFolder在打开时指定选中的文件夹且显示以桌面为根目录的顺序
发布网友
发布时间:2022-04-26 07:43
我来回答
共1个回答
热心网友
时间:2023-10-08 23:01
你好,我写了一段代码测试是可以的,你可以试一下。代码如下:function SelectFolder()
Const MY_COMPUTER = &H11
Const WINDOW_HANDLE = &H0
Const OPTIONS = 0
Const BIF_returnonlyfsdirs = &H0001
Const BIF_editbox= &H0010
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set WshShell = Nothing
Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, "",NO_OPTIONS, strDesktop)
objFolder.Self.path="C:\"
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
init_save_path=objPath
SelectFolder=objPath
end Function
SelectFolder()
wscript.sleep("5000")