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);
Here are the results:
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}
I would expect to see multiple lines with VisualStudio.DTE What am I doing wrong? What should I expect to see?
Edit:
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?