BRL.Volumes.mod and ShellFolders

Started by _PJ_, July 23, 2020, 15:18:34

Previous topic - Next topic

_PJ_

There is a function
GetCustomDir(..)

Which takes an CSIDL Integer as argument.
Is there an alternative that might use GUID strings for special ShellFolders (Windows only) or, alternatively the GUID are represented as Int Arrays as are defined in BRL.Volumes.mod/vol_win.bmx

Global _FOLDERID_*

But there exists no converstion to "friendly" CSIDL Integer constant in that file for the required directory (notably,  It has no CSIDL here
https://docs.microsoft.com/en-gb/windows/win32/shell/knownfolderid?redirectedfrom=MSDN
)

Since Windows users of other languages will have differently named folders, I cannot force a relative path from the "UserProfile" either.

One alternative may be to use a separate Extern to grab registry entries and retrieve the full path from
HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

However, this registry key is typically a legacy feature, so may not be reliable in future.

Does anyone have a workaround to obtain the full real path for a particulalr Known ShellFolder which does not have a 'friendly' CSIDL, but does have an Int Array _FOLDERID_* listed in "vol_win.bmx" ?

Henri

Hi,

you can call SHGetKnownFolderPath directly. It support folderID's (GUIDS as I understand them)

Something like:
Code (blitzmax) Select


Import brl.volumes

Local b:Short Ptr

SHGetKnownFolderPath(_FOLDERID_Videos, 0, 0, Varptr b)

Local dir:String = String.fromWString(b)
CoTaskMemFree(b)

Print dir


-Henri
- Got 01100011 problems, but the bit ain't 00000001

_PJ_

Henri! You are   a genius and lifesaver!
That works perfectly, thanks very much.

Scaremonger

Hi,
Brucey has a volumes module available that is cross platform. Might be worth a look in his library:

https://github.com/maxmods/bah.mod

Si...

Henri

Hi Scaremonger,

you might have been out for a while as volumes is now part of the core modules of NG as hinted in the example.

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Scaremonger

Oh, cool...

Yes, I've been away from Blitzmax/NG for a while now.