In a 32-bit VCL Application in Windows 10 in Delphi 11 Alexandria, I have a TRzShellTree
control (by Ray Konopka from the Konopka Signature VCL Controls 7.0 available in GetIt):
object RzShellTree1: TRzShellTree
Left = 0
Top = 41
Width = 201
Height = 428
Align = alLeft
BaseFolder.Pidl = {
004301000014001F50E04FD020EA3A6910A2D808002B30309D19002F433A5C00
00000000000000000000000000000000000054003100000000003D5465581100
44454C50484900003E0009000400EFBE1423F90E42549B502E00000000930F00
000001000000000000000000000000000000DFED4800440045004C0050004800
4900000016005A0031000000000042546956100053757065724D525500004200
09000400EFBE2154F655425469562E000000210A000000004B00000000000000
0000000000000000C43CDA00530075007000650072004D005200550000001800
660031000000000042546F56100050524F4A45437E3100004E0009000400EFBE
4254695642546F562E00000043EB0A0000000B00000000000000000000000000
000008E22E00500052004F004A004500430054002000470052004F0055005000
5300000018000000}
Indent = 19
ReadOnly = True
SelectionPen.Color = clBtnShadow
TabOrder = 0
OnChange = RzShellTree1Change
OnDragOver = RzShellTree1DragOver
end
...where in the TRzShellTree.OnAddItem
event handler I need to get the PATH of each added folder:
procedure TformMain.RzShellTreeGroupsAddItem(Sender: TObject; ParentIShf: IShellFolder_NRC; ParentAbsIdList, ItemRelIdList: PItemIDList; Attribs: Integer; var AllowAdd: LongBool);
begin
// How to get the PATH of the added folder?
end;
I assume this could be done by extracting the path from the ItemRelIdList: PItemIDList
parameter. But I don't know how to do that.
CodePudding user response:
If you need the full path, then combine the ParentAbsIdList
and ItemRelIdList
lists into a new absolute PItemIDList
list:
How do I convert a relative PIDL into an absolute PIDL?
And then use SHGetPathFromIDList()
.
If you just need the name of the new folder within its parent folder, you can just use ParentIShf.GetDisplayNameOf()
instead, passing it ItemRelIdList
as-is.