-addexstyle => WS_EX_TOPMOST, #### ########################################################################### # (@)METHOD:BrowseForFolder(%OPTIONS) # Displays the standard "Browse For Folder" dialog box. Returns the # selected item's name, or undef if no item was selected or an error # occurred. # # Allowed B<%OPTIONS> are: # -title => STRING # the title for the dialog # -computeronly => 0/1 (default 0) # only enable computers to be selected # -domainonly => 0/1 (default 0) # only enable computers in the current domain or workgroup # -driveonly => 0/1 (default 0) # only enable drives to be selected # -editbox => 0/1 (default 0) # if 1, the dialog will include an edit field in which # the user can type the name of an item # -folderonly => 0/1 (default 0) # only enable folders to be selected # -includefiles => 0/1 (default 0) # the list will include files as well folders # -owner => WINDOW # A Win32::GUI::Window or Win32::GUI::DialogBox object specifiying the # owner window for the dialog box # -printeronly => 0/1 (default 0) # only enable printers to be selected # -directory => PATH # the default start directory for browsing # -root => PATH or CONSTANT # the root directory for browsing; this can be either a # path or one of the following constants (minimum operating systems or # Internet Explorer versions that support the constant are shown in # square brackets. NT denotes Windows NT 4.0, Windows 2000, XP, etc.): # # CSIDL_FLAG_CREATE (0x8000) # [2000/ME] Combining this with any of the constants below will create the folder if it does not already exist. # CSIDL_ADMINTOOLS (0x0030) # [2000/ME] Administrative Tools directory for current user # CSIDL_ALTSTARTUP (0x001d) # [All] Non-localized Startup directory in the Start menu for current user # CSIDL_APPDATA (0x001a) # [IE4] Application data directory for current user # CSIDL_BITBUCKET (0x000a) # [All] Recycle Bin # CSIDL_CDBURN_AREA (0x003b) # [XP] Windows XP directory for files that will be burned to CD # CSIDL_COMMON_ADMINTOOLS (0x002f) # [2000/ME] Administrative Tools directory for all users # CSIDL_COMMON_ALTSTARTUP (0x001e) # [All] Non-localized Startup directory in the Start menu for all users # CSIDL_COMMON_APPDATA (0x0023) # [2000/ME] Application data directory for all users # CSIDL_COMMON_DESKTOPDIRECTORY (0x0019) # [NT] Desktop directory for all users # CSIDL_COMMON_DOCUMENTS (0x002e) # [IE4] My Documents directory for all users # CSIDL_COMMON_FAVORITES (0x001f) # [NT] Favorites directory for all users # CSIDL_COMMON_MUSIC (0x0035) # [XP] Music directory for all users # CSIDL_COMMON_PICTURES (0x0036) # [XP] Image directory for all users # CSIDL_COMMON_PROGRAMS (0x0017) # [NT] Start menu "Programs" directory for all users # CSIDL_COMMON_STARTMENU (0x0016) # [NT] Start menu root directory for all users # CSIDL_COMMON_STARTUP (0x0018) # [NT] Start menu Startup directory for all users # CSIDL_COMMON_TEMPLATES (0x002d) # [NT] Document templates directory for all users # CSIDL_COMMON_VIDEO (0x0037) # [XP] Video directory for all users # CSIDL_CONTROLS (0x0003) # [All] Control Panel applets # CSIDL_COOKIES (0x0021) # [All] Cookies directory # CSIDL_DESKTOP (0x0000) # [All] Namespace root (shown as "Desktop", but is parent to my computer, control panel, my documents, etc.) # CSIDL_DESKTOPDIRECTORY (0x0010) # [All] Desktop directory (for desktop icons, folders, etc.) for the current user # CSIDL_DRIVES (0x0011) # [All] My Computer (drives and mapped network drives) # CSIDL_FAVORITES (0x0006) # [All] Favorites directory for the current user # CSIDL_FONTS (0x0014) # [All] Fonts directory # CSIDL_HISTORY (0x0022) # [All] Internet Explorer history items for the current user # CSIDL_INTERNET (0x0001) # [All] Internet root # CSIDL_INTERNET_CACHE (0x0020) # [IE4] Temporary Internet Files directory for the current user # CSIDL_LOCAL_APPDATA (0x001c) # [2000/ME] Local (non-roaming) application data directory for the current user # CSIDL_MYMUSIC (0x000d) # [All] My Music directory for the current user # CSIDL_MYPICTURES (0x0027) # [2000/ME] Image directory for the current user # CSIDL_MYVIDEO (0x000e) # [XP] Video directory for the current user # CSIDL_NETHOOD (0x0013) # [All] My Network Places directory for the current user # CSIDL_NETWORK (0x0012) # [All] Root of network namespace (Network Neighbourhood) # CSIDL_PERSONAL (0x0005) # [All] My Documents directory for the current user # CSIDL_PRINTERS (0x0004) # [All] List of installed printers # CSIDL_PRINTHOOD (0x001b) # [All] Network printers directory for the current user # CSIDL_PROFILE (0x0028) # [2000/ME] The current user's profile directory # CSIDL_PROFILES (0x003e) # [XP] The directory that holds user profiles (see CSDIL_PROFILE) # CSIDL_PROGRAM_FILES (0x0026) # [2000/ME] Program Files directory # CSIDL_PROGRAM_FILES_COMMON (0x002b) # [2000] Directory for files that are used by several applications. Usually Program Files\Common # CSIDL_PROGRAMS (0x0002) # [All] Start menu "Programs" directory for the current user # CSIDL_RECENT (0x0008) # [All] Recent Documents directory for the current user # CSIDL_SENDTO (0x0009) # [All] "Send To" directory for the current user # CSIDL_STARTMENU (0x000b) # [All] Start Menu root for the current user # CSIDL_STARTUP (0x0007) # [All] Start Menu "Startup" folder for the current user # CSIDL_SYSTEM (0x0025) # [2000/ME] System directory. Usually \Windows\System32 # CSIDL_TEMPLATES (0x0015) # [All] Document templates directory for the current user # CSIDL_WINDOWS (0x0024) # [2000/ME] Windows root directory, can also be accessed via the environment variables %windir% or %SYSTEMROOT%. # void BrowseForFolder(...) PPCODE: BROWSEINFO bi; LPITEMIDLIST retval; LPITEMIDLIST pidl; LPSHELLFOLDER pDesktopFolder; OLECHAR olePath[MAX_PATH]; ULONG chEaten; HRESULT hr; int i, next_i; char folder[MAX_PATH]; char *option; ZeroMemory(&bi, sizeof(BROWSEINFO)); bi.pszDisplayName = folder; next_i = -1; for(i = 0; i < items; i++) { if(next_i == -1) { option = SvPV_nolen(ST(i)); if(strcmp(option, "-owner") == 0) { next_i = i + 1; bi.hwndOwner = (HWND) handle_From(NOTXSCALL ST(next_i)); } else if(strcmp(option, "-title") == 0) { next_i = i + 1; bi.lpszTitle = SvPV_nolen(ST(next_i)); } else BitmaskOption("-computeronly", bi.ulFlags, BIF_BROWSEFORCOMPUTER) } else BitmaskOption("-domainonly", bi.ulFlags, BIF_DONTGOBELOWDOMAIN) } else BitmaskOption("-driveonly", bi.ulFlags, BIF_RETURNFSANCESTORS) } else BitmaskOption("-editbox", bi.ulFlags, BIF_EDITBOX) } else BitmaskOption("-folderonly", bi.ulFlags, BIF_RETURNONLYFSDIRS) } else BitmaskOption("-includefiles", bi.ulFlags, BIF_BROWSEINCLUDEFILES) } else BitmaskOption("-printeronly", bi.ulFlags, BIF_BROWSEFORPRINTER) } else if(strcmp(option, "-directory") == 0) { next_i = i + 1; bi.lParam = (LPARAM) SvPV_nolen(ST(next_i)); bi.lpfn = BrowseForFolderProc; } else if(strcmp(option, "-root") == 0) { next_i = i + 1; if(SvIOK(ST(next_i))) { bi.pidlRoot = INT2PTR(LPCITEMIDLIST,SvIV(ST(next_i))); } else { SHGetDesktopFolder(&pDesktopFolder); MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, SvPV_nolen(ST(next_i)), -1, olePath, MAX_PATH ); hr = pDesktopFolder->ParseDisplayName( // hr = IShellFolder::ParseDisplayName( NULL, NULL, olePath, &chEaten, &pidl, NULL ); if(FAILED(hr)) { W32G_WARN("Win32::GUI::BrowseForFolder: can't get ITEMIDLIST for -root!"); pDesktopFolder->Release(); XSRETURN_UNDEF; } else { bi.pidlRoot = pidl; pDesktopFolder->Release(); } } } } else { next_i = -1; } } retval = SHBrowseForFolder(&bi); if(retval != NULL) { if(SHGetPathFromIDList(retval, folder)) { EXTEND(SP, 1); XST_mPV( 0, folder); XSRETURN(1); } else { XSRETURN_UNDEF; } } else { XSRETURN_UNDEF; }