问题描述
我想实现一个平台独立的文件/目录树浏览器。基本上,我试图复制Windows资源管理器的树控件来浏览计算机。但是,我不知道如何找到桌面或我的电脑文件夹字符串(它在每个pc和os类型,版本和语言更改)。如果我可以找到一种方法来获取最顶层的文件夹字符串,比我可以遍历和填充树希望。是否有注册表字符串在某个地方?
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?
最初,我将只瞄准MS Windows os'es(XP,Vista等),但后来我计划支持Linux和Macs好。我使用wxWidgets为我的GUI,但我对所有建议这个特定的问题。
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.
推荐答案
忽略可移植性,你需要的是PIDL树。 PIDL是文件路径的泛化。您可以使用获取特殊文件夹的PIDL。桌面为 CSIDL_DESKTOP
(不是 CSIDL_DESKTOPDIRECTORY
),我的电脑 CSIDL_DRIVES
。
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
.
要将PIDL转换为名称,请查看
To convert the PIDLs to names, have a look at SHGetNameFromIDList
这篇关于Windows资源管理器,如文件夹树浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!