枚举ROT条目 [英] Enumerate ROT Entries

查看:121
本文介绍了枚举ROT条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下C#代码枚举ROT条目:

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));
            }
        }
    }
}



如果我有运行Information.Typename()的Excel或Word,则仅返回应用程序".有没有一种方法可以显示ROT条目的完整ProgId(例如"Excel.Application").



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.

推荐答案

尝试以下链接:

http://www.jose.it-berater.org/smfforum/index.php? topic = 2266.0 [ ^ ]
try the following link:

http://www.jose.it-berater.org/smfforum/index.php?topic=2266.0[^]


感谢您的链接.我已经设法从ROT获取DisplayNames-我不知道如何获取ROT条目的ProgId.作为一种解决方法,我可以使用ole32.dll中的CLSIDFromProgID()获取条目的clsid并在注册表中查找值,但是我希望有一个更优雅的解决方案.
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.


这篇关于枚举ROT条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆