gpt4 book ai didi

c++ - IShellFolder::ParseDisplayName 以获取控制面板项的 ITEMIDLIST

转载 作者:行者123 更新时间:2023-11-28 05:25:36 24 4
gpt4 key购买 nike

我有一个 Shell 文件夹,它是一个控制面板项。我正在尝试获取相同的 ITEMIDLIST。我有 Shell 文件夹 GUID。

看文档

https://msdn.microsoft.com/en-us/library/windows/desktop/bb775090%28v=vs.85%29.aspx

https://msdn.microsoft.com/en-us/LIBRary/ms909875.aspx , 不一致

并声明我可以在桌面文件夹的::{GUID} 语法中指定显示名称,我试过了

::{CLSID for Control Panel}\::{CLSID for my Shell folder}.

然而,这不起作用,因为我最终得到的是控制面板的 ITEMIDLIST。如何将 ITEMIDLIST 获取到控制面板项目?

根据@Denis Anisimov 建议的答案,我仍然面临 ParseDisplayName 的问题。

int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
HRESULT hres;
LPSHELLFOLDER cPanel;
LPSHELLFOLDER DesktopFolder;
LPITEMIDLIST cpItemPidl;
LPITEMIDLIST pidl;
SHGetDesktopFolder(&DesktopFolder);
SHGetKnownFolderIDList(FOLDERID_ControlPanelFolder, CSIDL_CONTROLS, NULL, &pidl);
hres = DesktopFolder->BindToObject(pidl, NULL, IID_IShellFolder, (void**)&cPanel);
LPWSTR SFOLDERGUID = L"::{025A5937-A6BE-4686-A844-36FE4BEC8B6D}";

hres = cPanel->ParseDisplayName(NULL, NULL, SFOLDERGUID, NULL, &cpItemPidl, NULL);
}

我得到 hres 为

E_INVALIDARG One or more arguments are invalid.

最佳答案

我工作项目的一部分(它是 Delphi,但主要原理是可见的):

function CreatePluginsPIDL: PItemIDList;
var
ControlPanelPIDL: PItemIDList;
PluginsParsingName: UnicodeString;
Desktop: IShellFolder;
ControlPanelFolder: IShellFolder;
Eaten: DWORD;
Attr: DWORD;
Child: PItemIDList;
begin
ControlPanelPIDL := GetKnownFolderIDList(FOLDERID_ControlPanelFolder, CSIDL_CONTROLS);
try
OleCheck(SHGetDesktopFolder(Desktop));
try
OleCheck(Desktop.BindToObject(ControlPanelPIDL, nil, IShellFolder, ControlPanelFolder));
try
PluginsParsingName := '::' + GUIDToString(TTC4ShellCPNamespaceCLSID);
Attr := 0;
OleCheck(ControlPanelFolder.ParseDisplayName(0, nil, PWideChar(PluginsParsingName), Eaten, Child, Attr));
try
Result := ILCombine_(ControlPanelPIDL, Child);
finally
CoTaskMemFree(Child);
end;
finally
ControlPanelFolder := nil;
end;
finally
Desktop := nil;
end;
finally
CoTaskMemFree(ControlPanelPIDL);
end;
end;

关于c++ - IShellFolder::ParseDisplayName 以获取控制面板项的 ITEMIDLIST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40591374/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com