Windows Media Services SDK banner art
PreviousNext

Property Map Example

You can use the IPropertyMap interface to retrieve properties from different context objects. For example, the user name property of the user context object can be retrieved through this interface. To get the user name from the user context object, you must:

  1. Declare a pointer to the user context object.

  2. Declare a pointer to the IPropertyMap interface implemented by the user context object.

  3. Declare and initialize a variable to hold the user name.

  4. Pass the IPropertyMap interface identifier (ID) into the QueryInterface() method supported by the user context object, and get the address of a pointer that points to the IPropertyMap interface.

  5. Retrieve the user name by using the Read() method supported by the IPropertyMap interface.

The following code demonstrates how to retrieve the user name from the user context:

  INSSUserContext* pUser;
//Declare a pointer that points to the user context object.

  IPropertyMap* pIUserPropMap;
//Declare a pointer that points to the IpropertyMap interface.

  HRESULT hres;

  VARIANT UserName;
//Declare a VARIANT type of variable that will hold the user name.

  VariantInit(&UserName);
//Call the VariantInit() method to initialize the variable

  hres = pUser->QueryInterface(IID_IPropertyMap,
           (void**) &pIUserPropMap);
//Pass in IID_IpropertyMap and get the address of a pointer that points 
//to the interface.

  hres = pIUserPropMap->Read(_T("NSS_USER_NAME"),
              &userName);

//Retrieve the user name through the Read() method supported by the interface.

Note   You must initialize the variable UserName before you call the Read() method each time you retrieve the user name property.

PreviousNext


© 1996-1999 Microsoft Corporation. All rights reserved.