Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following C# code to enumerate ROT entries:

using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using Microsoft.VisualBasic;


namespace EnumRot
{
    class Program
    {
        [DllImport("ole32.dll")]
        public static extern void CreateBindCtx(
            int reserved, out IBindCtx ppbc);

        [DllImport("ole32.dll")]
        public static extern void GetRunningObjectTable(
            int reserved,
            out IRunningObjectTable prot);

        static void Main()
        {
            IRunningObjectTable rot;
            IEnumMoniker enumMoniker;
            IntPtr fetched = IntPtr.Zero;
            IMoniker[] Moniker = new IMoniker[1];

            GetRunningObjectTable(0, out rot);
            rot.EnumRunning(out enumMoniker);
            enumMoniker.Reset();

            while (enumMoniker.Next(1, Moniker, fetched) == 0)
            {
                IBindCtx bindCtx;
                string displayName;
                object ComObject;

                CreateBindCtx(0, out bindCtx);
                Moniker[0].GetDisplayName(bindCtx, null, out displayName);
                rot.GetObject(Moniker[0], out ComObject);

                Console.WriteLine("-----------------------------------");
                //Console.WriteLine(displayName);
                Console.WriteLine(Information.TypeName(ComObject));
            }
        }
    }
}


If I have Excel or Word running Information.Typename() returns only "Application". Is there a way to display the full ProgId (like "Excel.Application") for ROT entries.
Posted

 
Share this answer
 
Thank you for the link. I already managed to get DisplayNames from ROT - I can't figure out how to get ProgIds of ROT entries. As a workaround, I can use CLSIDFromProgID() from ole32.dll to get a clsid for an entry and look the value up in registry, but I was hoping for a more elegant solution.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900