Bau das ganze mal so etwa so um:
Delphi-Quellcode:
var
aContextMenu: IContextMenu;
aContextMenu2: IContextMenu2;
// ...
begin
// ...
aContextMenu.QueryContextMenu(aPopup, 0, 1, $7FFF, CMF_EXPLORE
or CMF_CANRENAME);
aContextMenu.QueryInterface(IID_IContextMenu2, aContextMenu2);
//To handle submenus.
try
aCmd:=Integer(TrackPopupMenu(aPopup, TPM_LEFTALIGN
or TPM_LEFTBUTTON
or TPM_RIGHTBUTTON
or
TPM_RETURNCMD, X, Y, 0,
Handle,
nil));
finally
aContextMenu2 :=
nil;
end;
if aCmd<>0
then
// ...
Ungetestet. genaueres erfährst du in der ShellCtrls.pas im Delphi-Ordner unter Demos\ShellControls, wenn du nach InvokeContextMenu suchst.