如何将相对的PIDL转换为绝对的PIDL? [英] How do I convert a relative PIDL into an absolute PIDL?
问题描述
我想使用 SHGetFileInfo
获取Windows控制面板图标,我使用Shell获取Windows控制面板代码:
I want to use SHGetFileInfo
to get windows control panel icon,I use Shell to get windows control panel
Code:
var
psfDeskTop: IShellFolder;
psfWork: IShellFolder;
pidworkDir: PITEMIDLIST;
pidChild: PITEMIDLIST;
pEnumList: IEnumIDList;
celtFetched: ULONG;
//chEaten, dwAttributes: ULONG;
FileInfo: SHFILEINFOW;
//conGUID: string;
StrRetName: TStrRet;
Name: PChar;
begin
SHGetDesktopFolder(psfDeskTop);
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
//here I want to use SHGetFileInfo to get file icon
//but , SHGetFileInfo need a absolute PIDL,IEnumIDList enumerates relative PIDL
end
end;
我找到了一个名为 ILCombine 可以做到这一点,但是我在Delphi中找不到,我想知道是否可以结合使用pidworkDir和pidChild在Delphi中获得绝对的PIDL?
I found a function called ILCombine in MSDN to do that , but I can't found in Delphi , I wonder if possible to combine pidworkDir and pidChild to get a absolute PIDL in Delphi?
或者还有其他获取文件图标的方法吗?
Or is there any other way to get a file's icon?
推荐答案
您确实可以调用 ILCombine
(来自Delphi).您需要使用 ShlObj
单元.
You can indeed call ILCombine
from Delphi. You need to use the ShlObj
unit.
uses
ShlObj;
....
pidItemAbsolute = ILCombine(pidworkDir, pidChild);
如果您的Delphi没有声明 ILCombine
,则可以这样导入它:
If your Delphi doesn't have ILCombine
declared then you can import it like this:
function ILCombine(pidl1, pidl2: PItemIDList): PItemIDList;
stdcall; external 'shell32.dll';
这篇关于如何将相对的PIDL转换为绝对的PIDL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!