我发现当我在“搜索控制面板”中输入文字时,它可以找到一些控制惩罚设置。
所以我想通过windows shell或其他方式枚举所有设置
var
psfDeskTop: IShellFolder;
psfControl: IShellFolder;
pidControl: PITEMIDLIST;
pidChild: PITEMIDLIST;
pidAbsolute: PItemIdList;
pEnumList: IEnumIDList;
celtFetched: ULONG;
FileInfo: SHFILEINFOW;
begin
OleCheck(SHGetDesktopFolder(psfDeskTop));
OleCheck(SHGetSpecialFolderLocation(0, CSIDL_CONTROLS, pidControl));
OleCheck(psfDeskTop.BindToObject(pidControl, nil, IID_IShellFolder, psfControl));
OleCheck(psfControl.EnumObjects(0, SHCONTF_NONFOLDERS or SHCONTF_INCLUDEHIDDEN or SHCONTF_FOLDERS, pEnumList));
while pEnumList.Next(1, pidChild, celtFetched) = 0 do
begin
pidAbsolute := ConcatPIDLs(pidControl, pidChild);
SHGetFileInfo(LPCTSTR(pidAbsolute), 0, FileInfo, SizeOf(FileInfo), SHGFI_PIDL
or SHGFI_DISPLAYNAME);
// SHGetFileInfo can get name and icon
//Do something to save item name and icon
end;
end;
此代码无法获取特定设置,只需获取所有控制面板项。所以我找到了一个叫做GodMode它可以在控制面板中显示所有设置
代码 :
var
psfDeskTop : ISHellFolder;
psfGodeMode : ISHellFolder;
pidGodMode : PITEMIDLIST;
pidAbsolute : PITEMIDLIST;
pidChild : PITEMIDLIST;
pEnumList : IEnumIDList;
cbEaten : ULONG;
dwAttribute : ULONG;
celtFetched: ULONG;
begin
SHGetDesktopFolder(psfDeskTop);
psfDeskTop.ParseDisplayName(0, nil,
'::{ED7BA470-8E54-465E-825C-99712043E01C}', cbEaten, pidGodMode,
dwAttribute);
psfDeskTop.BindToObject(pidGodMode, nil, IID_IShellFolder,
psfGodeMode);
//Get error in this line
psfGodeMode.EnumObjects(0, SHCONTF_NONFOLDERS or SHCONTF_FOLDERS,
pEnumList);
while pEnumList.Next(0, pidChild, celtFetched) = 0 do
begin
//....
end;
end;
但它不起作用,所以我的问题是:有没有办法枚举 Windows 控制面板中的所有设置?