/* Implements IActiveScriptSite::GetItemInfo Tries to find the QAxBase for \a pstrName and returns the relevant interfaces in \a item and \a type as requested through \a mask. */ HRESULT WINAPI QAxScriptSite::GetItemInfo(LPCOLESTR pstrName, DWORD mask, IUnknown **item, ITypeInfo **type) { if (item) *item = 0; else if (mask & SCRIPTINFO_IUNKNOWN) return E_POINTER; if (type) *type = 0; else if (mask & SCRIPTINFO_ITYPEINFO) return E_POINTER; QAxBase *object = script->findObject(QString::fromUtf16((const ushort*)pstrName)); if (!object) return TYPE_E_ELEMENTNOTFOUND; if (mask & SCRIPTINFO_IUNKNOWN) object->queryInterface(IID_IUnknown, (void**)item); if (mask & SCRIPTINFO_ITYPEINFO) { IProvideClassInfo *classInfo = 0; object->queryInterface(IID_IProvideClassInfo, (void**)&classInfo); if (classInfo) { classInfo->GetClassInfo(type); classInfo->Release(); } } return S_OK; }
STDMETHODIMP ActiveScriptImpl::GetItemInfo( /* [in] */ LPCOLESTR pstrName, /* [in] */ DWORD dwReturnMask, /* [out] */LPUNKNOWN* ppiunkItem, /* [out] */LPTYPEINFO* ppti) { if (dwReturnMask & SCRIPTINFO_ITYPEINFO) { if (!ppti) return E_INVALIDARG; *ppti = NULL; } if (dwReturnMask & SCRIPTINFO_IUNKNOWN) { if (!ppiunkItem) return E_INVALIDARG; *ppiunkItem = NULL; } LPUNKNOWN lpUnknown = namedItems.get(pstrName); if (NULL == lpUnknown) { ATLTRACE("No IUnknown for item!\n"); // This shouldn't ever happen, since we're providing the items return TYPE_E_ELEMENTNOTFOUND; } if (dwReturnMask & SCRIPTINFO_ITYPEINFO) { // Use IProvideClassInfo to get ITypeInfo of coclass! IProvideClassInfo *pci = NULL; HRESULT hr = lpUnknown->QueryInterface(IID_IProvideClassInfo, (void**)&pci); if (SUCCEEDED(hr) && pci) { hr = pci->GetClassInfo(ppti); } // Release interface if (pci) pci->Release(); if (FAILED(hr)) return E_FAIL; } if (dwReturnMask & SCRIPTINFO_IUNKNOWN) { *ppiunkItem = lpUnknown; int *pInt = weakItems.get(pstrName); if (!pInt) (*ppiunkItem)->AddRef(); // because returning else *pInt = (*pInt) + 1; } return S_OK; }
ITypeInfo *tCOMUtil::GetCoClassTypeInfo(IUnknown* punk) { HRESULT hr = S_OK; IProvideClassInfo *pIProvideClassInfo = NULL; ITypeInfo* coclassinfo = NULL; hr = punk->QueryInterface(IID_IProvideClassInfo, (void **) &pIProvideClassInfo); if (FAILED(hr)) return NULL; hr = pIProvideClassInfo->GetClassInfo(&coclassinfo); pIProvideClassInfo->Release(); if(SUCCEEDED(hr)) return coclassinfo; else return NULL; }
static void get_coclassname( IUnknown *punk, VARIANT *vres ) { HRESULT hr; IProvideClassInfo *pPCI; ITypeInfo *pTI; BSTR bstr = NULL; hr = punk->QueryInterface( IID_IProvideClassInfo, (void **)&pPCI ); if ( SUCCEEDED(hr) && pPCI != NULL ) { hr = pPCI->GetClassInfo( &pTI ); if ( SUCCEEDED(hr) && pTI != NULL ) { hr = pTI->GetDocumentation( MEMBERID_NIL, &bstr, NULL, NULL, NULL ); pTI->Release(); } pPCI->Release(); } if ( bstr == NULL ) { bstr = SysAllocString( L"" ); } vres->bstrVal = bstr; vres->vt = VT_BSTR; }