IMessengerContact::Blocked
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.
Sets or retrieves a Boolean value that declares whether the contact associated with this MessengerContact object. Not scriptable.
Syntax
HRESULT Blocked(
[out, retval] VARIANT_BOOL* pBoolBlock
);
HRESULT Blocked(
[in] VARIANT_BOOL* pBoolBlock
);
Parameters
- pBoolBlock
Pointer to a variable of type VARIANT_BOOL that receives whether this user is blocked by the current client user. VARIANT_TRUE indicates that the user is blocked. VARIANT_FALSE indicates that the user is not blocked.
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.
- S_FALSE
Attempted to block an already blocked user or unblock a user who was not blocked.
- E_FAIL
A general internal failure occurred.
- DISP_E_BADVARTYPE
The VARIANT handling library returned an error.
- E_OUTOFMEMORY
The VARIANT handling library returned an error.
- E_INVALIDARG
The argument requested an out-of-range property. This is not normally returned through this interface because the API calls a property that is known to be in range.
Remarks
Blocking is not necessarily reciprocal. User A might have blocked User B, but if User B has not blocked User A, User A can still receive status updates about User B if User B is on User A's contact list. Blocking a user does not remove the user from the contact list or the MessengerContacts collection. Clients should decide how to enforce a logical relationship between blocking users and removing blocked users from the contact list.
Assuming the MessengerContact object can be successfully created (which can only be done with an online client), calling this method against a MessengerContact object while the client is offline always return pBoolBlock==FALSE, even if the contact in question really is blocked. Property information cannot be determined while offline, but do not throw an error.
Example
The example demonstrates reading and setting the Blocked status of a contact. If the MessengerContact object is null, the attempt to read the Blocked property raises a COMException. To avoid the overhead of processing the exception, the code first checks to see if the MessengerContact object exists. If the contact Blocked status is true, the status is set to false. If false, the Blocked is set to true.
if (contact != null)
{
try
{
if (contact.Blocked == true)
contact.Blocked = false;
else
contact.Blocked = true;
}
catch (COMException CEB)
{
Console.WriteLine(CEB.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