using System.Runtime.InteropServices; using Microsoft.Win32; using System; class Program { static void Main() { // Get the ROT IBindCtx bindCtx = null; if (CreateBindCtx(0, out bindCtx) == 0 && bindCtx != null) { IRunningObjectTable rot = null; if (bindCtx.GetRunningObjectTable(out rot) == 0 && rot != null) { // Enumerate through the active objects in the ROT IEnumMoniker monikerEnum = null; if (rot.EnumRunning(out monikerEnum) == 0 && monikerEnum != null) { monikerEnum.Reset(); IMoniker[] monikers = new IMoniker[1]; IntPtr fetchedMonikerCountPtr = Marshal.AllocHGlobal(4); int fetchedMonikerCount; while (monikerEnum.Next(1, monikers, fetchedMonikerCountPtr) == 0) { // TODO: Process the active object } } } } } [DllImport("ole32.dll")] static extern int CreateBindCtx(uint reserved, out IBindCtx ppbc); }
using System; using System.Runtime.InteropServices; using Microsoft.Win32; class Program { static void Main(string[] args) { // Get the ROT IRunningObjectTable rot = null; if (GetRunningObjectTable(0, out rot) == 0 && rot != null) { // Enumerate through the active objects in the ROT IEnumMoniker monikerEnum = null; if (rot.EnumRunning(out monikerEnum) == 0 && monikerEnum != null) { monikerEnum.Reset(); IMoniker[] monikers = new IMoniker[1]; IntPtr fetchedMonikerCountPtr = Marshal.AllocHGlobal(4); int fetchedMonikerCount; while (monikerEnum.Next(1, monikers, fetchedMonikerCountPtr) == 0) { // TODO: Process the active object } } } } [DllImport("ole32.dll")] static extern int GetRunningObjectTable(uint reserved, out IRunningObjectTable prot); }This code example is very similar to the previous one, but instead of using IBindCtx.GetRunningObjectTable to retrieve the ROT, it uses the GetRunningObjectTable method. This code is also likely part of a larger package or program, as it is not sufficient to be a standalone package. The package library cannot be determined with only this code example.