获取Windows上所有用户的开始菜单的路径 [英] Get path to all users' start menu on Windows
本文介绍了获取Windows上所有用户的开始菜单的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种方法来检索C ++中所有用户的开始菜单目录的路径.我只能(使用Qt)获得当前用户之一:
I am looking for a way to retrieve the path to the all users start menu directory in C++. I am only able to get the one of the current user (using Qt):
QString startMenuPath = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).at(0);
但是,Qt不允许为所有用户检索一个.据我所知,也没有包含该路径的环境变量可供我读取.
However, Qt does not allow to retrieve the one for all users. As far as I know there also is no environment variable containing that path, that I could read.
推荐答案
要获取已知文件夹,请使用 CSIDL
到所需的文件夹.
To get a known folder, use SHGetFolderPath
, and pass a KNOWNFOLDERID
or CSIDL
for the desired folder.
例如,以下代码获取所有用户Start Menu
和Programs
文件夹:
For example, the following code gets the All Users Start Menu
and the Programs
folder:
// Remember to #include <Shlobj.h>
WCHAR path[MAX_PATH];
HRESULT hr = SHGetFolderPathW(NULL, CSIDL_COMMON_PROGRAMS, NULL, 0, path);
if (SUCCEEDED(hr))
std::wcout << L"Start Menu\Programs: " << path << std::endl;
hr = SHGetFolderPathW(NULL, CSIDL_COMMON_STARTMENU, NULL, 0, path);
if (SUCCEEDED(hr))
std::wcout << L"Start Menu: " << path << std::endl;
这篇关于获取Windows上所有用户的开始菜单的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文