[Win32utils-devel] Getting virtual folder information

Heesob Park phasis at gmail.com
Fri Sep 26 00:59:04 EDT 2008


Hi,

2008/9/26 Berger, Daniel <Daniel.Berger at qwest.com>:
> Hi,
>
> One of the problems with SHGetFolderPath is that it doesn't work for
> virtual folders. I _think_ we can get it with SHGetFolderLocation, but
> I'm not positive, as I'm having a bit of trouble making it work.
>
> Any ideas on how to get, say, the value of CSIDL_DRIVES? I mean, it
> should be "My Computer", but I want to get it programmatically.
>
require 'windows/shell'
include Windows::Shell

pidl = 0.chr * 4
SHGetSpecialFolderLocation(0, CSIDL_DRIVES, pidl)
# size of SHFILEINFO is 692 bytes
info = 0.chr * 692
# 0x200 says get display name, 0x8 says PIDL, not path.
SHGetFileInfo(pidl.unpack('L').first,0, info ,692,0x208)
folder = info[12..-1].strip

Regards,

Park Heesob


More information about the win32utils-devel mailing list