Share via


IMessengerContacts::Count

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Retrieves the number of IMessengerContact objects in the collection. Not scriptable.

Syntax

HRESULT Count(
   [out,
   retval] LONG* pcContacts
);

Parameters

  • pcContacts
    LONG that provides the number of IMessengerContact objects in the collection.

Return Value

Returns one of the following values. For managed code applications, these return values are received in the form of a COMException.

  • S_OK
    Success.
  • RPC_X_NULL_REF_POINTER
    pcContacts is a null pointer.

Remarks

If there are no active IMessengerContact objects in the contact list, pcContacts returns zero.

If this method is called while the client is offline, the method call does not fail, but the contact list always has zero members and zero count.

Example

The example code instantiates and fills a collection of IMessengerContact objects by querying the IMessenger::MyContacts property of communicator. If the contact collection is not null, the count of items in the collection is retrieved by querying the Count property. Finally, the contact count is displayed on the application console window.

IMessengerContacts messengerContacts = (IMessengerContacts)communicator.MyContacts;
if (messengerContacts != null)
{
   try
   {
      Console.WriteLine("Contacts Count: " + messengerContacts.Count;
   }
   catch (COMException CE)
   {
     Console.WriteLine("Contacts Count COM exception: " + CE.ErrorCode.ToString());
   }
}

Requirements

  • Client
    Requires Microsoft DirectX 9.0, C Runtime libraries (msvcm80.dll) on Microsoft Windows© Vista, Microsoft Windows XP Service Pack 1 (SP1) or later, or Microsoft Windows 2000 with Service Pack 4 (SP4). Any Communicator-imposed restrictions apply. .
  • Server
    Requires Microsoft Office Communications Server 2007, AV MCU (for Media Support), Media Relay (for NAT/Firewall traversal) on Microsoft Office Communications Server 2007.
  • Product
    Microsoft Office Communicator 2007 Automation API
  • IDL file
    Msgrua.idl

See Also

Reference

IMessengerContacts::Item