Exemplo n.º 1
0
void EnumTypeLib(ITypeLib *typeLib, EnumTypeLibProc pfn)
{
    UINT count = typeLib->GetTypeInfoCount();
    for (UINT i = 0; i < count; i++)
    {
        ITypeInfoPtr typeInfo;
        typeLib->GetTypeInfo(i, &typeInfo);
        TYPEATTR *typeAttr = NULL;
        typeInfo->GetTypeAttr(&typeAttr);
        pfn(typeInfo, typeAttr);
        typeInfo->ReleaseTypeAttr(typeAttr);
    }
}
Exemplo n.º 2
0
HRESULT GetDispatchProperty(IDispatch* pDisp, LPOLESTR lpName, VARIANT* pRes)
{
#ifdef _DEBUG
	ITypeInfoPtr pTypeInfo;
	LPTYPEATTR pTypeAttr;
	pDisp->GetTypeInfo(1, GetSystemDefaultLCID(), &pTypeInfo);
	pTypeInfo->GetTypeAttr(&pTypeAttr);
	pTypeInfo->ReleaseTypeAttr(pTypeAttr);
#endif
	DISPID DispId = 0;
	HRESULT hr = pDisp->GetIDsOfNames(IID_NULL, &lpName, 1, GetSystemDefaultLCID(), &DispId);
	if (hr != S_OK)
		return hr;
	_variant_t varRes;
	unsigned int ArgError;
	DISPPARAMS Params;
	Params.cArgs = 0;
	Params.rgvarg = NULL;
	Params.cNamedArgs = 0;
	Params.rgdispidNamedArgs = NULL;
	hr = pDisp->Invoke(DispId, IID_NULL, GetSystemDefaultLCID(), DISPATCH_PROPERTYGET, &Params, pRes, NULL, &ArgError);
	return hr;
}