Share via


IMessengerContacts::Item method

[Item is no longer available for use as of Windows Vista. See Windows Messenger for more information.]

Retrieves a specific service by index.

Syntax

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

Parameters

Index [in]

Type: long

LONG that specifies the index of the desired MessengerContacts object in the collection.

ppMContact [out, retval]

Type: IDispatch**

Address of a pointer to an IDispatch interface on a MessengerContacts object requested with Index. The object can now be accessed through the IMessengerContact interface.

Return value

Type: HRESULT

Returns one of the following values.

Return code Description
S_OK
Success.
RPC_X_NULL_REF_POINTER
ppMContact is a NULL pointer.
E_FAIL
Invalid collection or index number provided exceeds the length of the collection.
E_INVALIDARG
Index is not a positive integer.

Remarks

The following table lists error codes returned by this method.

Error Code Meaning
0x80004005 Invalid collection, or index number provided exceeds the length of the collection.
0x80070057 Index is not a positive integer.

The Contacts property is scriptable, but read-only.

If you know the sign-in name for a user, you can get the MessengerContact object by creating an object for it explicitly by calling GetContact. Even if that contact is already present in a list, the same pointer is returned (as it would have been by retrieving that object from an existing collection).

Note

This method is available for scripting languages.

Examples

The following Visual Basic example shows the use of this method.

Public WithEvents MsgrUIA As MessengerAPI.Messenger
Public MsgrContacts As MessengerAPI.IMessengerContacts

Private Sub btnItem_Click()
    On Error Resume Next
    FormItem.Show vbModal   'Get user input
    If bDialogCancel = False Then
        MsgBox("Contacts Item " & lItem & " = " & _
        MsgrContacts.Item(lItem).SigninName & " : " & _
        MsgrContacts.Item(lItem).FriendlyName)
    End If
    ErrorTrap ("Contact.Item")  'Error handling routine
End Sub

Requirements

End of client support
Windows XP
End of server support
Windows Server 2003
Header
Msgrua.h
IDL
Msgrua.idl
DLL
Msgsc.dll

See also

IMessengerContacts

MessengerContact