After searching all over the web...
I finally found one great answer (10x God!!!) written by Egil Hogholt.
http://www.egilh.com/blog/archive/2005/02/25/557.aspx
I have copied the C# version of the code which was written in one of
the comments (Thanks to Mark).
Take a look at the code:
using System;
using System.Runtime.InteropServices;
namespace ptdpc
{
/// <summary>
/// Summary description for ComMonitor.
/// </summary>
public class ComMonitor
{
static public void GetData()
{
// Get an instance of the internal com+ tracker objet
Type comPlusTrackerType = Type.GetTypeFromCLSID(new
System.Guid("{ecabafb9-7f19-11d2-978e-0000f8757e2a}"));
COMSVCSLib.IGetAppData getAppData =
(COMSVCSLib.IGetAppData)Activator.CreateInstance(comPlusTrackerType);
// Step through the list of running application
uint appCount;
IntPtr appDataPtr = new IntPtr();
unsafe
{
getAppData.GetApps(out appCount, new
IntPtr(&appDataPtr));
}
int appDataSize =
Marshal.SizeOf(typeof(COMSVCSLib.appData));
for (int appIndex = 0; appIndex < appCount; appIndex++)
{
COMSVCSLib.appData appData = (COMSVCSLib.appData)
Marshal.PtrToStructure(new IntPtr(appDataPtr.ToInt32()
+ (appIndex * appDataSize)), typeof(COMSVCSLib.appData));
Console.WriteLine("AppID={0}",
GetString(appData.m_szAppGuid));
// Application information
Console.Write("ID={0}", appData.m_idApp);
Console.Write(", PID={0}", appData.m_dwAppProcessId);
Console.WriteLine();
Console.Write("Calls/Sec={0}",
appData.m_AppStatistics.m_cCallsPerSecond);
Console.Write(", Total Calls={0}",
appData.m_AppStatistics.m_cTotalCalls);
Console.Write(", Class Count={0}",
appData.m_AppStatistics.m_cTotalClasses);
Console.Write(", Instnc Count={0}",
appData.m_AppStatistics.m_cTotalInstances);
Console.WriteLine();
uint nClsIDCount;
IntPtr clsIDDataPtr;
unsafe
{
getAppData.GetAppData(appData.m_idApp, out
nClsIDCount, new IntPtr(&clsIDDataPtr));
}
int clsIDDataSize =
Marshal.SizeOf(typeof(COMSVCSLib.CLSIDDATA));
for (int clsIDIndex = 0; clsIDIndex < nClsIDCount;
clsIDIndex++)
{
COMSVCSLib.CLSIDDATA clsIDData =
(COMSVCSLib.CLSIDDATA)
Marshal.PtrToStructure(new
IntPtr(clsIDDataPtr.ToInt32() + (clsIDIndex * clsIDDataSize)),
typeof(COMSVCSLib.CLSIDDATA));
Console.WriteLine("\tCLSID={0}",
clsIDData.m_clsid.ToString());
// Performance information
Console.Write("\tBound={0}", clsIDData.m_cBound);
Console.Write(", References={0}",
clsIDData.m_cReferences);
Console.Write(", Pooled={0}", clsIDData.m_cPooled);
Console.WriteLine();
Console.Write("\tCallsCompleted={0}",
clsIDData.m_cCallsCompleted);
Console.Write(", CallsFailed={0}",
clsIDData.m_cCallsFailed);
Console.Write(", InCall={0}", clsIDData.m_cInCall);
Console.Write(", RespTime={0}",
clsIDData.m_dwRespTime);
Console.WriteLine();
Console.WriteLine();
}
Marshal.FreeCoTaskMem(clsIDDataPtr);
}
Marshal.FreeCoTaskMem(appDataPtr);
Marshal.ReleaseComObject(getAppData);
}
static string GetString(ushort[] arr)
{
byte[] buf = new byte[arr.Length * 2];
for (int i = 0; i < arr.Length; i++)
{
buf[i * 2] = (byte)(arr
& 0xFF);
buf[i * 2 + 1] = (byte)(arr >> 8);
}
string s =
System.Text.UnicodeEncoding.Unicode.GetString(buf);
return s;
}
}
}
This code uses an undocumented object which i guess is microsoft's way
to show the stats inside DCOMCNFG console...
I can only ask "WHY!!!" this object is not documented ?
Iddo