IShellFolder::ParseDisplayName获取控制面板项目的ITEMIDLIST



我有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);
}

我得到了

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;

相关内容

  • 没有找到相关文章

最新更新