如何在 XP 和 Vista 中可靠地获取 Quick Launch 文件夹? [英] How do you reliably get the Quick Launch folder in XP and Vista?

查看:22
本文介绍了如何在 XP 和 Vista 中可靠地获取 Quick Launch 文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要在 Vista 和 XP 下为所有用户和当前用户可靠地获取快速启动文件夹.我正在使用 C++ 进行开发,但这可能更像是一个通用的 Windows API 问题.

We need to reliably get the Quick Launch folder for both All and Current users under both Vista and XP. I'm developing in C++, but this is probably more of a general Windows API question.

作为参考,这里是获取两个系统下的Application Data文件夹的代码:

For reference, here is code to get the Application Data folder under both systems:

    HRESULT hres; 
    CString basePath;
    hres = SHGetSpecialFolderPath(this->GetSafeHwnd(), basePath.GetBuffer(MAX_PATH), CSIDL_APPDATA, FALSE);
    basePath.ReleaseBuffer();

我怀疑这只是知道 Microsoft 使用哪个子文件夹的问题.

I suspect this is just a matter of knowing which sub-folder Microsoft uses.

在 Windows XP 下,应用数据子文件夹为:

Under Windows XP, the app data subfolder is:

Microsoft\Internet Explorer\快速启动

Microsoft\Internet Explorer\Quick Launch

在Vista下,子文件夹好像改成了:

Under Vista, it appears that the sub-folder has been changed to:

漫游\Microsoft\Internet Explorer\快速启动

Roaming\Microsoft\Internet Explorer\Quick Launch

但我想确保这是确定正确位置的正确方法.

but I'd like to make sure that this is the correct way to determine the correct location.

找到确定此位置的正确方法非常重要,因为当您进入国际安装等时,依赖硬编码的文件夹名称几乎总是会中断......文件夹已命名的事实Vista 中的漫游"让我想知道是否有一些与该文件夹相关的特殊处理(类似于 XP 下的本地设置文件夹).

Finding the correct way to determine this location is quite important, as relying on hard coded folder names almost always breaks as you move into international installs, etc... The fact that the folder is named 'Roaming' in Vista makes me wonder if there is some special handling related to that folder (akin to the Local Settings folder under XP).

以下 msdn 文章:http://msdn.microsoft.com/en-us/library/bb762494.aspx 表示 CSIDL_APPDATA 具有 FOLDERID_RoamingAppData 的等效 ID,这似乎支持 StocksR 的断言,即 CSIDL_APPDATA 确实返回 C:\Users\xxxx\AppData\Roaming,因此应该可以使用CSIDL_APPDATA 的相同相对路径以快速启动 (\Microsoft\Internet Explorer\Quick Launch).

The following msdn article: http://msdn.microsoft.com/en-us/library/bb762494.aspx indicates that CSIDL_APPDATA has an equivalent ID of FOLDERID_RoamingAppData, which does seem to support StocksR's assertion that CSIDL_APPDATA does return C:\Users\xxxx\AppData\Roaming, so it should be possible to use the same relative path for CSIDL_APPDATA to get to quick launch (\Microsoft\Internet Explorer\Quick Launch).

因此以下算法对每个 MS 都是正确的:

So the following algorithm is correct per MS:

HRESULT hres; 
CString basePath;
hres = SHGetSpecialFolderPath(this->GetSafeHwnd(), basePath.GetBuffer(MAX_PATH), CSIDL_APPDATA, FALSE);
basePath.ReleaseBuffer();
CString qlPath = basePath + "\\Microsoft\\Internet Explorer\\Quick Launch";

检查小时以确保对 SHGetSpecialFolderPath 的调用成功也是一个好主意.

it would also be a good idea to check hres to ensure that the call to SHGetSpecialFolderPath was successful.

推荐答案

vista 上的 AppData 指的是 C:\Users\xxxx\AppData\Roaming 而不是 C:\Users\xxxx\AppData 文件夹本身.

AppData on vista refers to C:\Users\xxxx\AppData\Roaming not the C:\Users\xxxx\AppData folder it's self.

还有这篇文章 http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0901.mspx 在微软网站上意味着你只需要使用相对于 appdata 文件夹的路径

Also this artical http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0901.mspx on a microsoft site implies that you simply have to use the path relative to the appdata folder

这篇关于如何在 XP 和 Vista 中可靠地获取 Quick Launch 文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆