本文介绍了枚举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.
推荐答案
这篇关于枚举ROT条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!