This document is archived and information here might be outdated.  Recommended version.


IAppROT.Count Property (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (Framework)  

IAppROT.Count Property

The count of application references within the running object table.

[Visual Basic .NET]
Public ReadOnly Property Count As Integer
[C#]
public int Count {get;}

Product Availability

Available with ArcGIS Desktop.

Remarks

The following example uses AppROT's Count property to determine if any applications are already running. You would get m_app from the hook in ICommand::OnCreate().

[C#]
IAppROT appRot=new AppROTClass();
if (appRot.Count > 0)
{
  for (int i=0; i < appRot.Count; i++)
  {
    if (appRot.get_Item(i) is IMxApplication)
      System.Windows.Forms.MessageBox.Show("ArcMap is running.");
    else if (appRot.get_Item(i) is IGxApplication)
      System.Windows.Forms.MessageBox.Show("ArcCatalog is running.");
  }
}
[Visual Basic .NET]
Dim appRot As IAppROT=New AppROTClass()
If appRot.Count > 0 Then
 Dim i As Integer=0
 While i < appRot.Count
  If TypeOf appRot.get_Item(i) Is IMxApplication Then
   System.Windows.Forms.MessageBox.Show("ArcMap is running.")
  ElseIf TypeOf appRot.get_Item(i) Is IGxApplication Then
   System.Windows.Forms.MessageBox.Show("ArcCatalog is running.")
  End If
  System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
 End While
End If

See Also

IAppROT Interface