Retrieves a specific service by index. Scriptable.

Syntax

HRESULT Item(
   [in] long Index,
   [out,
   retval] IDispatch** ppService
);

Parameters

Index

[in] LONG that specifies the index of the desired IMessengerServices object in the collection.

ppService

[out, retval] Address of a pointer to an IDispatch interface on a IMessengerServices object requested with Index. The object can now be accessed through the IMessengerServices interface.

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.

E_FAIL

The invalid collection or index number provided exceeds the length of the collection.

RPC_X_NULL_REF_POINTER

ppService is a null pointer.

E_INVALIDARG

Index is not a positive integer.

Remarks

The service collection object is a zero-based array of IMessengerService objects. Therefore, passing 0 as a parameter to the Item method returns the first object in the collection.

If you know the name for that specific service, you can get the IMessengerServices object by creating an object for it explicitly by calling IMessengerService::ServiceName method. Even if that service is already present in a list, the same pointer is returned as it would have been by retrieving that object from an existing collection.

Example

The following code example examines the IMessenger::Services property on the IMessenger object, communicator, to get a collection of Communicator services. If the collection is not null and holds at least one service, the code instantiates an IMessengerService object. The ServiceName property of the service is displayed in the application console window.

Copy Code
IMessengerServices serviceCollection;
serviceCollection = (IMessengerServices)communicator.Services;
if (serviceCollection.Count > 0 && serviceCollection != null)
{
   try
   {
	IMessengerService firstService = (IMessengerService)serviceCollection.Item(0);
	Console.WriteLine(firstService.ServiceName);
   }
   catch (COMException SCCE)
   {
	 Console.WriteLine("COM Exception " + SCCE.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

IMessengerServices