delphi - How to get the shell image index of an object in the shell namespace? -
i want index in system imagelist of object in shell namespace.
if object file use shgetfileinfo:
function getfileimageindex(const filename: string): integer; var sfi: tshfileinfo; begin shgetfileinfo(pchar(filename), file_attribute_normal, sfi, sizeof(sfi), shgfi_usefileattributes or shgfi_sysiconindex); result := sfi.iicon; end; except don't have file
the thing have doesn't exist on hard-drive folder or file, e.g.:
control panelhomegroupnetwork
but still need index in system imagelist of icon corresponds thing. started shgetfileinfo (as supports pidls). fell apart. tried using iextracticon, fell apart:
function getobjectimageindex(parentfolder: ishellfolder; const childpidl: pitemidlist): integer; //var // sfi: tshfileinfo; // extracticon: iextracticon; // iconfile: widestring; // iconindexinfile: integer; // flags: cardinal; begin { function shell namespace equivalent of getfileimageindex helper function. } (* won't work (msdn: "the pidl must qualified pidl. relative pidls not allowed.") shgetfileinfo(pwidechar(childpidl), file_attribute_normal, sfi, sizeof(sfi), shgfi_pidl or shgfi_sysiconindex); *) (* won't work. doesn't return index system imagelist parentfolder.getuiobjectof(0, 1, childpidl, iextracticon, nil, {out}extracticon); setlength(iconfile, max_path); extracticon.geticonlocation(0, pwidechar(iconfile), length(iconfile), iconindexinfile, {out}flags); *) result := -1; //todo: figure out how it. end; given ishellfolder , pidl in folder, how icon in system imagelist of thing?
the simple answer pass absolute pidl identifies object shgetfileinfo. tried without success, way solve problem.
you should go shgetfileinfo , make work. looks got far having relative pidl , stopped. make absolute pidl ilcombine , should home.
if don't have pidl containing ishellfolder you'll want read topic: how obtain pidl of ishellfolder
Comments
Post a Comment