Archive: Select only local drive and folder from browse dialog window


Select only local drive and folder from browse dialog window
I am using NSD_CreateBrowseButton with nsDialogs::SelectFolderDialog "" "" in my installer for bower for folder dialog. But this lists all the drives,folders and network folder and mapped drives.But i want user to only select the local drives and folders. So he should not select network path and also mapped network drives. So i need either these network folders to not come in browse dialog. If it is not possible to do in NSIS then i need to display a message if he selects a network folder or mapped network drive. How it can be done?


So that the user must select a local folder ...

Function check_drive_type
; validate installation drive type
; example: '\\Network\C\folder\' returns 4 - the path is on a network
${GetRoot} $0 $R0 ; returns the drive or root '$R0'
StrCpy $R0 "$R0\" ; root plus backslash
System::Call 'kernel32::GetDriveType(t R0) i.R0'
# DRIVE_UNKNOWN = 0
# DRIVE_NO_ROOT_DIR = 1
# DRIVE_REMOVABLE = 2
# DRIVE_FIXED = 3
# DRIVE_REMOTE = 4
# DRIVE_CDROM = 5
# DRIVE_RAMDISK = 6
${If} $R0 != 3 ; 3 is a fixed drive type
MessageBox MB_USERICON|MB_OK "This location cannot be selected.$\r$\nPlease choose another path." /SD IDOK
Abort
${EndIf}
FunctionEnd
To eliminate the user selecting the root, C:\ or D:\ ...

Function check_folder
StrLen $R0 $0
${If} $R0 < 4
MessageBox MB_USERICON|MB_OK "Please choose a valid folder." /SD IDOK
Abort
${EndIf}
FunctionEnd

Just remember that on Win2000+ you can mount a removable drive in a folder and Vista+ supports symlinks to network shares... :)