Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
System Folders and string interpretations
#1
I would appreciate it if the following two inquiries could be dealt with :

1. Is it possible to start BrowseForFolder with initial string "My Computer" and if yes how?

2. I understand that system folder "$17$" is interpreted to "My Computer" . I also understand that some routine can give as its output the string
Quote::: 14001F50E04FD020EA3A6910A2D808002B30309D
which is the expanded path of "$17$". I am wondering whether there exists a fast way to convert ":: ...." to its conventional equivalent "My Computer".

Many thanks in advance.
#2
1. Now BrowseForFolder initDir cannot be a non-file-system folder. In next QM can, eg ":: 14001F50E04FD020EA3A6910A2D808002B30309D" or "$17$" for "My Computer". BrowseForFolder of next QM:

Function BrowseForFolder
Code:
Copy      Help
;/
function# str&s [$initDir] [flags] [$text] [hwndOwner] ;;flags: 1 include files, 2 include non-file objects (Control Panel, etc), 4 new style

;Shows "Browse For Folder" dialog for selecting a folder.
;Returns a nonzero value on OK, 0 on Cancel.

;s - variable that receives full path of selected folder.
;;;With flag 2 it is <help #IDP_SEARCHPATHS>ITEMIDLIST string</help> if a non-file object selected.
;initDir - initially display this folder in the dialog.
;;;Without flag 4 displays only this folder and subfolders. With flag 4 displays all folders and selects/expands this folder.
;flags:
;;;1, 2, 4 - see above.
;;;Flag 4 changes dialog style, adds more features.
;;;Also can include BIF_x flags (see <google "site:microsoft.com BROWSEINFO">BROWSEINFO</google>), left-shifted by 8 bits. For example, to browse for computer, use 2|(WINAPI.BIF_BROWSEFORCOMPUTER<<8).
;text - text to display above the folder list.
;hwndOwner (QM 2.3.4) - owner window handle. It will be disabled.
;;;If omitted or 0, will use the active window, if it belongs to current thread. To create unowned dialog, use GetDesktopWindow for hwndOwner.

;EXAMPLE
;str s
;if(!BrowseForFolder(s "$windows$" 4)) ret
;out s


BROWSEINFOW b
if(!hwndOwner) hwndOwner=win; if(GetWindowThreadProcessId(hwndOwner 0)!=GetCurrentThreadId) hwndOwner=0
b.hwndOwner=hwndOwner
if(flags&1) b.ulFlags|BIF_BROWSEINCLUDEFILES
if(flags&2=0) b.ulFlags|BIF_RETURNONLYFSDIRS
if(flags&4) b.ulFlags|BIF_USENEWUI
b.ulFlags|flags>>8
b.lpszTitle=@text
if(!empty(initDir)) ITEMIDLIST* initPidl=PidlFromStr(initDir)
if(flags&4) b.lpfn=&sub.Callback
else b.pidlRoot=initPidl ;;BFFM_SETEXPANDED does not work with old-style

ITEMIDLIST* pidl=SHBrowseForFolderW(&b)

if(pidl) PidlToStr(pidl &s flags&2=0); CoTaskMemFree pidl; else s.all
CoTaskMemFree initPidl
0
ret s.len


#sub Callback v
function# hwnd uMsg lParam !*lpData

sel uMsg
,case BFFM_INITIALIZED
,if(initPidl) SendMessage hwnd BFFM_SETEXPANDED 0 initPidl
,case BFFM_SELCHANGED
,if(flags&6=4 and _winnt<6) SendMessage hwnd BFFM_ENABLEOK 0 PidlToStr(+lParam &_s 1) ;;xp bug fix

2.
Macro ITEMIDLIST to display name
Code:
Copy      Help
ITEMIDLIST* pidl=PidlFromStr(":: 14001F50E04FD020EA3A6910A2D808002B30309D")
;or ITEMIDLIST* pidl=PidlFromStr(_s.expandpath("$17$"))
SHFILEINFOW x
int ok=SHGetFileInfoW(+pidl 0 &x sizeof(x) SHGFI_PIDL|SHGFI_DISPLAYNAME)
CoTaskMemFree pidl
if(!ok) end "failed"
str s.ansi(&x.szDisplayName)
out s
#3
Dear Gintaras,

Many thanks indeed for superb solutions. Have a nice weekend. Best Regards, Simos.
#4
I'm running Windows 8.1
When I use this
Macro Macro78
Code:
Copy      Help
if(!BrowseForFolder(s "::{14001F50E04FD020EA3A6910A2D808002B30309D}" 4)) ret
out s
It always points to "C:\users\<username>" folder only.

But if I try this

Macro Macro79
Code:
Copy      Help
if(!BrowseForFolder(s "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" 4)) ret
out s
It will point to "My Computer" folder.
#5
Quote:if(!BrowseForFolder(s "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" 4)) ret

Tested: works on Windows 10 too, but not on Windows XP and 7.


Forum Jump:


Users browsing this thread: 1 Guest(s)