I use Shell to get control panel
Code:
procedure TForm1.FormCreate(Sender: TObject);
var
psfDeskTop: IShellFolder;
psfWork: IShellFolder;
pidworkDir: PITEMIDLIST;
pidChild: PITEMIDLIST;
pEnumList: IEnumIDList;
celtFetched: ULONG;
FileInfo: SHFILEINFOW;
begin
Memo1.Clear;
SHGetDesktopFolder(psfDeskTop);
//control panel
SHGetSpecialFolderLocation(0, CSIDL_CONTROLS, pidworkDir);
psfDeskTop.BindToObject(pidworkDir, nil, IID_IShellFolder, psfWork);
psfWork.EnumObjects(0, SHCONTF_NONFOLDERS or SHCONTF_FOLDERS or SHCONTF_INCLUDEHIDDEN, pEnumList);
while pEnumList.Next(1, pidChild, celtFetched) = 0 do
begin
SHGetFileInfo(LPCTSTR(pidChild), 0, FileInfo, SizeOf(FileInfo), SHGFI_PIDL
or SHGFI_TYPENAME or SHGFI_DISPLAYNAME or SHGFI_USEFILEATTRIBUTES);
Memo1.Lines.Add(FileInfo.szDisplayName + ' +');
end;
end;
it can't get FileInfo.szDisplayName
, i just use ' +'
to make Memo1 dispaly.
Why can't get control panel name ?
I'm not an expert on the shell. In fact I know practically nothing. But by reading the documentation I can glean the following:
SHGetFileInfo
expects an absolute PIDL.IEnumIDList
enumerates relative PIDLs.So you code is bound to fail because of that. Perhaps there are other errors too. I can't tell.
Anyway, I think the easy way to solve the problem is to use
IShellFolder.GetDisplayNameOf
to obtain the name you need: