DisplaySpecifiers 容器
显示说明符通过区域设置存储在 Configuration 容器的 DisplaySpecifiers 容器中。 由于配置容器在整个林中复制,因此显示说明符将跨林中的所有域传播。
配置容器存储 DisplaySpecifiers 容器,然后存储对应于每个区域设置的容器。 这些区域设置容器使用区域设置标识符的十六进制表示形式命名。 例如,美国/英语区域设置容器命名为 409,德语区域设置的容器命名为 407,日语区域设置的容器命名为 411。 有关详细信息,以及可能的语言标识符列表,请参阅语言标识符常量和字符串。
每个区域设置容器存储 displaySpecifier 类的对象。
若要列出区域设置的所有显示说明符,请枚举 DisplaySpecifiers 容器中指定区域设置容器中的所有 displaySpecifier 对象。
以下代码示例包含绑定到指定区域设置的显示说明符容器的函数:
/**********
This function returns a pointer to the display specifier container
for the specified locale.
If locale is NULL, use default system locale and then return the
locale in the locale parameter.
***********/
HRESULT BindToDisplaySpecifiersContainerByLocale(
LCID *locale,
IADs **ppDispSpecCont)
{
HRESULT hr = E_FAIL;
if ((!ppDispSpecCont)||(!locale))
return E_POINTER;
// If no locale is specified, use the default system locale.
if (!(*locale))
{
*locale = GetSystemDefaultLCID();
if (!(*locale))
return E_FAIL;
}
// Be sure that the locale is valid.
if (!IsValidLocale(*locale, LCID_SUPPORTED))
return E_INVALIDARG;
LPOLESTR szPath = new OLECHAR[MAX_PATH*2];
IADs *pObj = NULL;
VARIANT var;
hr = ADsOpenObject(L"LDAP://rootDSE",
NULL,
NULL,
ADS_SECURE_AUTHENTICATION,
IID_IADs,
(void**)&pObj);
if (SUCCEEDED(hr))
{
// Get the DN to the configuration container.
hr = pObj->Get(CComBSTR("configurationNamingContext"), &var);
if (SUCCEEDED(hr))
{
// Build the string to bind to the container for the
// specified locale in the DisplaySpecifiers container.
swprintf_s(
szPath,
L"LDAP://cn=%x,cn=DisplaySpecifiers,%s",
*locale,
var.bstrVal);
// Bind to the container.
*ppDispSpecCont = NULL;
hr = ADsOpenObject(szPath,
NULL,
NULL,
ADS_SECURE_AUTHENTICATION,
IID_IADs,
(void**)ppDispSpecCont);
if(FAILED(hr))
{
if ((*ppDispSpecCont))
{
(*ppDispSpecCont)->Release();
(*ppDispSpecCont) = NULL;
}
}
}
}
// Cleanup.
VariantClear(&var);
if (pObj)
pObj->Release();
return hr;
}