了解运行对象表 [英] Understanding the Running Object Table

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

问题描述

我在尝试使用运行对象表得到一个DTE Visual Studio中的一个具体实例。我正打算使用在 MSDN <描述的技术/ A>。我已经设法获得实例列表中的一个,而不是其他。

I'm attempting to use the running object table to get a DTE a specific instance of Visual Studio. I was intending to use the technique described on MSDN. I've managed to get one of the instances to list, but not the others.

public static void PrintRot()
{
    IRunningObjectTable rot;
    IEnumMoniker enumMoniker;
    int retVal = GetRunningObjectTable(0, out rot);

    if (retVal == 0)
    {
        rot.EnumRunning(out enumMoniker);

        IntPtr fetched = IntPtr.Zero;
        IMoniker[] moniker = new IMoniker[1];
        while (enumMoniker.Next(1, moniker, fetched) == 0)
        {
            IBindCtx bindCtx;
            CreateBindCtx(0, out bindCtx);
            string displayName;
            moniker[0].GetDisplayName(bindCtx, null, out displayName);
            Console.WriteLine("Display Name: {0}", displayName);
        }
    }
}

[DllImport("ole32.dll")]
private static extern void CreateBindCtx(int reserved, out IBindCtx ppbc);

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

下面是结果:

Display Name: !VisualStudio.DTE.11.0:7120
Display Name: clsid:331F1768-05A9-4DDD-B86E-DAE34DDC998A:
Display Name: !{7751A556-096C-44B5-B60D-4CC78885F0E5}
Display Name: c:\users\dave\documents\visual studio 2012\Projects\MyProj\MyProj.sln
Display Name: !{059618E6-4639-4D1A-A248-1384E368D5C3}

我希望看到多行与VisualStudio.DTE我究竟做错了什么?我应该期望看到

I would expect to see multiple lines with VisualStudio.DTE What am I doing wrong? What should I expect to see?

编辑:

这似乎与应用程序是否在运行提升权限。如果我是一致的,正常使用模式,然后它的作品。不过,我想,无论它的工作,我怎么得到所有进程的ROT?

It seems related to whether the app is running elevated privileges. If I'm consistent and use normal mode then it works. However, I'd like it to work regardless, how do I get the ROT for all processes?

推荐答案

您运行的另一个实例升高吗?你是高架运行exe文件?

are you running another instance elevated? are you running the exe elevated?

当你运行作为一个标准用户的过程,你只能看到属于你的进程/等。所以你不会看到正在以管理员身份运行的进程。

When you are a process running as a standard user, you can only see processes/etc that belong to you. So you wouldn't see processes that are running as administrator.

在使用升级特权时运行,你可以看到属于所有用户的所有进程。

When running with escalated priviliges, you can see all processes belonging to all users.

在理想情况下,一切都将始终运行的最低特权用户,看到的 http://en.wikipedia.org/wiki/Principle_of_least_privilege

Ideally, everything would always run as the "least privileged user", see http://en.wikipedia.org/wiki/Principle_of_least_privilege

这篇关于了解运行对象表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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