IEvalRat::TestRating Method

This topic applies to Windows XP Service Pack 1 or later.
The TestRating method determines whether a program with the specified rating should be blocked.

Syntax

HRESULT TestRating(
  [in]  EnTvRat_System enShowSystem,
  [in]  EnTvRat_GenericLevel enShowLevel,
  [in]  LONG lbfEnShowAttributes
);

Parameters

  • enShowSystem [in]
    Specifies the rating system, as an EnTvRat_System enumeration type.

  • enShowLevel [in]
    Specifies the rating level, as an EnTvRat_GenericLevel enumeration type. The meaning of this value depends on the rating system.

  • lbfEnShowAttributes [in]
    Bitwise combination of zero or more flags from the BfEnTvRat_GenericAttributes enumeration. The flags specify content attributes, such as violence or adult language. Content attributes do not apply to all rating systems.

Return Value

The method returns an HRESULT. Possible values include those in the following table.

Return code Description

E_INVALIDARG

Invalid argument.

S_FALSE

This program is restricted and should be blocked.

S_OK

This program is allowed and should not be blocked.

Remarks

The application sets viewing permissions through the IEvalRat::put_BlockedRatingAttributes method. Whenever the Decrypter/Detagger filter receives a new rating in a program, it calls TestRating to determine whether to block the program. If TestRating returns S_OK, the rating is restricted under the current set of viewing permissions, and the Decrypter/Tagger filter blocks the program.

Implementation Note:

For each supported rating system, store a table that contains bitmasks for each level within that system. On object creation, initialize each bitmask to zero. Update the bitmasks in the put_BlockedRatingAttributes method.

In the TestRating method, use the enShowSystem and enShowLevel parameters to perform a table lookup and get the corresponding bitmask. Return S_FALSE if either of the following tests are true:

  • The BfIsBlocked flag is set in the bitmask
  • Any attribute flag in lbfEnShowAttributes is also set in the bitmask.

Use a bitwise AND to test the bitmask. If neither test is true, return S_OK.

The following code shows a possible implementation. It assumes that the object stores the bitmasks in a two-dimensional array named Mask:

if ((0 != Mask[system][level] & BfIsBlocked) || 
    (0 != Mask[system][level] & attributes))
{
    return S_FALSE; // Blocked.
}
else
{
    return S_OK; // Not blocked.
}

Requirements

Header Declared in Tvratings.h.

See Also

IEvalRat Interface

Send comments about this topic to Microsoft

Build date: 12/4/2008