本文整理汇总了C++中IADs::get_Name方法的典型用法代码示例。如果您正苦于以下问题:C++ IADs::get_Name方法的具体用法?C++ IADs::get_Name怎么用?C++ IADs::get_Name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IADs
的用法示例。
在下文中一共展示了IADs::get_Name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintAllObjects
HRESULT PrintAllObjects(IADsContainer* pContainer)
{
HRESULT hr;
if(NULL == pContainer)
{
return E_INVALIDARG;
}
IEnumVARIANT *pEnum = NULL;
// Create an enumerator object in the container.
hr = ADsBuildEnumerator(pContainer, &pEnum);
if(SUCCEEDED(hr))
{
VARIANT var;
ULONG ulFetched = 0L;
// Get the next contained object.
while(S_OK == (hr = ADsEnumerateNext(pEnum, 1, &var, &ulFetched)) && (ulFetched > 0))
{
IADs *pADs;
// Print the object
hr = V_DISPATCH(&var)->QueryInterface(IID_IADs, (void**)&pADs);
if(SUCCEEDED(hr))
{
CComBSTR sbstr;
IADsContainer *pChildContainer;
hr = pADs->get_Name(&sbstr);
if(SUCCEEDED(hr))
{
wprintf(sbstr);
wprintf(L"\n");
}
hr = pADs->QueryInterface(IID_IADsContainer, (void**)&pChildContainer);
if(SUCCEEDED(hr))
{
// If the retrieved object is a container, recursively print its contents as well.
PrintAllObjects(pChildContainer);
}
pADs->Release();
}
// Release the VARIANT.
VariantClear(&var);
}
ADsFreeEnumerator(pEnum);
}
return hr;
}
示例2: PyIADs_getattro
PyObject* PyIADs_getattro(PyObject *ob, PyObject *obname)
{
char *name = PYWIN_ATTR_CONVERT(obname);
if (!name) return NULL;
IADs *p = PyIADs::GetI(ob);
// These are all BSTR values
BSTR ret = NULL;
HRESULT hr;
BOOL bad = FALSE;
Py_BEGIN_ALLOW_THREADS
// docs refer to 'property' as AdsPath, but function is ADsPath
// allow both
// @prop <o PyUnicode>|ADsPath|
// @prop <o PyUnicode>|AdsPath|Synonym for ADsPath
if (strcmp(name, "AdsPath")==0 || strcmp(name, "ADsPath")==0)
hr = p->get_ADsPath(&ret);
// @prop <o PyUnicode>|Class|
else if (strcmp(name, "Class")==0)
hr = p->get_Class(&ret);
// @prop <o PyUnicode>|GUID|Like the IADs method, this returns a string rather than a GUID object.
else if (strcmp(name, "GUID")==0)
hr = p->get_GUID(&ret);
// @prop <o PyUnicode>|Name|
else if (strcmp(name, "Name")==0)
hr = p->get_Name(&ret);
// @prop <o PyUnicode>|Parent|
else if (strcmp(name, "Parent")==0)
hr = p->get_Parent(&ret);
// @prop <o PyUnicode>|Schema|
else if (strcmp(name, "Schema")==0)
hr = p->get_Schema(&ret);
else
bad = TRUE;
Py_END_ALLOW_THREADS
if (bad)
return PyIBase::getattro(ob, obname);
if (FAILED(hr))
return PyCom_BuildPyException(hr, p, IID_IADs );
PyObject *rc = MakeBstrToObj(ret);
SysFreeString(ret);
return rc;
}