Src/Pscx.Core/Interop/RunningObjectTable/RunningObjectTableHelper.cs
/// <summary>
/// Get a snapshot of the running object table (ROT).
/// </summary>
/// <param name="filter">The filter to apply to the list (nullable).</param>
/// <returns>A hashtable of the matching entries in the ROT</returns>
Get a snapshot of the running object table (ROT).
Get a snapshot of the running object table ( ROT ) .
public static Hashtable GetActiveObjectList(string filter)
        {
            var result = new Hashtable();
            IntPtr numFetched = IntPtr.Zero;
            IRunningObjectTable runningObjectTable;
            IEnumMoniker monikerEnumerator;
            var monikers = new IMoniker[1];
            NativeMethods.GetRunningObjectTable(0, out runningObjectTable);
            runningObjectTable.EnumRunning(out monikerEnumerator);
            monikerEnumerator.Reset();
            while (monikerEnumerator.Next(1, monikers, numFetched) == 0)
            {
                IBindCtx ctx;
                NativeMethods.CreateBindCtx(0, out ctx);
                string runningObjectName;
                monikers[0].GetDisplayName(ctx, null, out runningObjectName);
                object runningObjectVal;
                runningObjectTable.GetObject(monikers[0], out runningObjectVal);
                if (string.IsNullOrEmpty(filter) || runningObjectName.IndexOf(filter, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    result[runningObjectName] = runningObjectVal;
                }
            }
            return result;
        }
public static Hashtable GetActiveObjectList ( string filter ) { var result = new Hashtable ( ) ; IntPtr numFetched = IntPtr . Zero ; IRunningObjectTable runningObjectTable ; IEnumMoniker monikerEnumerator ; var monikers = new IMoniker [ 1 ] ; NativeMethods . GetRunningObjectTable ( 0 , out runningObjectTable ) ; runningObjectTable . EnumRunning ( out monikerEnumerator ) ; monikerEnumerator . Reset ( ) ; while ( monikerEnumerator . Next ( 1 , monikers , numFetched ) == 0 ) { IBindCtx ctx ; NativeMethods . CreateBindCtx ( 0 , out ctx ) ; string runningObjectName ; monikers [ 0 ] . GetDisplayName ( ctx , null , out runningObjectName ) ; object runningObjectVal ; runningObjectTable . GetObject ( monikers [ 0 ] , out runningObjectVal ) ; if ( string . IsNullOrEmpty ( filter ) || runningObjectName . IndexOf ( filter , StringComparison . OrdinalIgnoreCase ) != - 1 ) { result [ runningObjectName ] = runningObjectVal ; } } return result ; }
Get a snapshot of the running object table (ROT).
Get a snapshot of the running object table ( ROT ) .
A hashtable of the matching entries in the ROT
A hashtable of the matching entries in the ROT
filter
string
The filter to apply to the list (nullable).
The filter to apply to the list ( nullable ) .