本文介绍了SelectFolderDialog 只有驱动器,驱动器内没有文件夹选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在文件夹选择窗口的 nsis SelectFolderDialog 中.但我想出现或用户只选择驱动器.驱动器内不应选择文件夹.所以用户应该得到像 C:D:E: 等的驱动器有没有办法做到这一点?

In nsis SelectFolderDialog for folder selection window. But i want to appear or user to select only drives.There should not be selection of folders inside a drive.So user should get drives like C: D: E: etcIs there any option to do it?

推荐答案

这只能让你在我的电脑里选择小于 4 个字符的路径,如果你想隐藏对话框中的文件夹你需要写一个插件并实现IFolderFilter(仅限 WinXP+)

This only allows you to select paths shorter than 4 characters inside My Computer, if you want to hide the folders in the dialog you need to write a plugin and implement IFolderFilter (WinXP+ only)

#BIF_RETURNONLYFSDIRS 0x00000001
#BIF_NEWDIALOGSTYLE 0x00000040
#BIF_NONEWFOLDERBUTTON 0x00000200
!include LogicLib.nsh
!include WinMessages.nsh
!define /math BFFM_ENABLEOK ${WM_USER} + 101
!define BFFM_SELCHANGED 2
System::Call 'SHELL32::SHGetSpecialFolderLocation(i0,i0x11,*i.r2)i.r0'
System::Get "(i.R0,i.R1,i.R2,i)iR9R9"
Pop $3
System::Call '*(i$hwndparent,i$2,i,t "Hello",i0x241,kr3,i0,i0)i.r1'
System::Call 'SHELL32::SHBrowseForFolder(ir1)i.r0'
Sys_BFFCALLBACK:
    ${If} $R9 == "callback1"
        ${If} ${BFFM_SELCHANGED} = $R1
            System::Call 'SHELL32::SHGetPathFromIDList(i$R2,t "" R9)'
            StrLen $R9 $R9
            ${IfThen} $R9 > 3 ${|} StrCpy $R9 0 ${|}
            SendMessage $R0 ${BFFM_ENABLEOK} 0 $R9
        ${EndIf}
        StrCpy $R9 0 ; return value
        System::Call $3
        Goto Sys_BFFCALLBACK
    ${EndIf}
System::Free $3 ; system callback
System::Call 'OLE32::CoTaskMemFree(ir2)' ; BROWSEINFO.pidlRoot
System::Free $1 ; BROWSEINFO
${If} $0 <> 0
    System::Call 'SHELL32::SHGetPathFromIDList(i$0,t "" R9)'
    MessageBox mb_ok SHBrowseForFolder=$R9
${EndIf}
System::Call 'OLE32::CoTaskMemFree(ir0)' ; pidl result

这篇关于SelectFolderDialog 只有驱动器,驱动器内没有文件夹选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 14:59