2

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;

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?

4

1 回答 1

4

你确实可以ILCombine从德尔福打电话。您需要使用本ShlObj机。

uses
  ShlObj;
....
pidItemAbsolute = ILCombine(pidworkDir, pidChild);

如果您的 Delphi 没有ILCombine声明,那么您可以像这样导入它:

function ILCombine(pidl1, pidl2: PItemIDList): PItemIDList; 
    stdcall; external 'shell32.dll';
于 2012-10-31T12:21:11.320 回答