views:

586

answers:

2

I am trying to implement a platform independent file/directory tree browser. Basically, I am trying to replicate windows explorer's tree control to browse the computer. However, I can't figure out how to find the "Desktop" or "My Computer" folder string (It changes in every pc and os type, version and language). If I can find a way to get the topmost folder string, than I can traverse down and populate the tree hopefully. Is there a registry string somewhere?

Initially, I will only target MS Windows os'es (XP, Vista, etc) but later I plan to support Linux and Macs as well. I use wxWidgets for my GUI but I am open to all suggestions for this specific problem. Oh, and I am using C++ in VS2008.

+1  A: 

Take a look at SHGetFolderPath function.

Nemanja Trifunovic
+2  A: 

Ignoring portability, what you need is the "PIDL" tree. PIDLs are generalizations of file paths. You can get the PIDLs for special folders with SHGetFolderLocation. The desktop is CSIDL_DESKTOP (not CSIDL_DESKTOPDIRECTORY), My Computer is CSIDL_DRIVES.

To convert the PIDLs to names, have a look at SHGetNameFromIDList

MSalters