uses
winapi.ActiveX,
win.ComObj,
winapi.UrlMon;
procedure test;
var
ROT: IRunningObjectTable;
Enum: IEnumMoniker;
Fetched: Integer;
RunningObj: IMoniker;
Name: PWideChar;
BindCtx: IBindCtx;
ClassID: TGUID;
ProgID: String;
Mk: IMoniker;
chEaten: ULONG;
DmyObj: IUnknown;
Datei: OLEVariant;
App: OLEVariant;
Z: Boolean;
i: Integer;
l: TListItem;
begin
ListView1.Items.Clear;
OleCheck(CreateBindCtx(0, BindCtx));
OleCheck(GetRunningObjectTable(0, ROT));
if ROT.EnumRunning(Enum) = S_OK then
begin
Enum.Next(1, RunningObj, @Fetched);
while RunningObj <> nil do
begin
RunningObj.GetDisplayName(BindCtx, nil, Name);
l := ListView1.Items.Add;
l.SubItems.Add(name);
try
RunningObj.GetClassID(ClassID);
ProgID := ClassIDToProgID(ClassID);
except
ProgID := '';
end;
l.SubItems.Add(ProgID);
if UpperCase(ProgID) = 'FILE' then
begin
try
OleCheck(CreateBindCtx(0, BindCtx));
OleCheck(MkParseDisplayNameEx(BindCtx, PWideChar(WideString(Name)), chEaten, Mk));
OleCheck(Mk.BindToObject(BindCtx, nil, IUnknown, DmyObj));
Datei := DmyObj as IDispatch;
try
App := Datei.Application;
l.SubItems.Add(app.name);
except
end;
except
end;
end;
Enum.Next(1, RunningObj, @Fetched);
end;
end;
for i := 0 to Pred(ListView1.Columns.Count) do
begin
ListView1.Column[i].Width := 10;
ListView1.Column[i].Width := -2;
end;
end;