本文整理汇总了C++中ITypeInfo::GetNames方法的典型用法代码示例。如果您正苦于以下问题:C++ ITypeInfo::GetNames方法的具体用法?C++ ITypeInfo::GetNames怎么用?C++ ITypeInfo::GetNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeInfo
的用法示例。
在下文中一共展示了ITypeInfo::GetNames方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetEventNames
HRESULT CJSProxyObj::SetEventNames()
{
ITypeInfo* pInfo;
if (m_pTypeInfo == nullptr)
pInfo = theApp.m_pEventTypeInfo.p;
else
pInfo = m_pTypeInfo.p;
TYPEATTR *pta = nullptr;;
HRESULT hr = pInfo->GetTypeAttr(&pta);
if (FAILED(hr))
return hr;
BSTR bstrName = ::SysAllocString(L"");
FUNCDESC *pfd = nullptr;
unsigned int uiNames = 0;
for (int i = 0; i < pta->cFuncs; i++)
{
hr = pInfo->GetFuncDesc(i, &pfd);
if (FAILED(hr))
continue;
hr = pInfo->GetNames(pfd->memid, &bstrName, 1, &uiNames);
if (SUCCEEDED(hr) && bstrName && SysStringLen(bstrName))
{
m_mapDispId.Add(pfd->memid, bstrName);
ATLTRACE(_T("*********Add function '%s' in Tangram*******\r\n"), OLE2T(bstrName));
}
pInfo->ReleaseFuncDesc(pfd);
pfd = nullptr;
}
pInfo->ReleaseTypeAttr(pta);
return hr;
}
示例2: ThrowComFail
JNIEXPORT jobjectArray JNICALL Java_org_racob_com_TypeInfo_getNames
(JNIEnv *env, jobject obj, jint pointer, jint memid) {
ITypeInfo *typeInfo = (ITypeInfo *) pointer;
BSTR names[MAX_NAMES];
unsigned int namesCount;
HRESULT hr = typeInfo->GetNames(memid, names, MAX_NAMES, &namesCount);
if (!SUCCEEDED(hr)) {
ThrowComFail(env, "getNames failed", hr);
return NULL;
}
// Make primitive String array for names
jclass autoClass = env->FindClass("java/lang/String");
jobjectArray array = env->NewObjectArray(namesCount, autoClass, NULL);
if (!SUCCEEDED(hr)) {
ThrowComFail(env, "getNames failed to make return array", hr);
return NULL;
}
// Fill up array
for (unsigned int i = 0; i < namesCount; i++) {
int len = SysStringLen(names[i]);
jstring string = env->NewString((const jchar *) names[i], len);
env->SetObjectArrayElement(array, i, string);
SysFreeString(names[i]);
}
return array;
}
示例3: compare
int Sorter::compare( VARIANT * elem_1, VARIANT * elem_2 )
{
HRESULT hr;
if( this->p_Compare != NULL )
{
DISPPARAMS dargs = { NULL, NULL, 0, 0 };
VARIANT vresult;
VariantInit(&vresult);
DISPID dp[1];
LPOLESTR name = L"callback_compare";
hr = p_Compare->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_SYSTEM_DEFAULT, dp);
// dp[0] contains id , not id=1 as specified in the IDL
hr = p_Compare->Invoke( dp[0], IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dargs, &vresult, NULL, NULL);
// nothing happens?
// other things I have tried:
name = L"QueryInterface";
hr = p_Compare->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_SYSTEM_DEFAULT, dp); // returns: E_UNKNOWN_NAME - why?
ITypeInfo * pIT;
hr = p_Compare->GetTypeInfo( NULL, LOCALE_SYSTEM_DEFAULT, &pIT );
UINT cNames = 0;
LPOLESTR rgszNames[1];
hr = pIT->GetNames( dp[0], rgszNames, 1, &cNames);
// rgszNames contians mysorter_callback_compare, the vba implementation
hr = S_OK;
}
return 0;
}
示例4: GetI
/**********88
PyObject *PyITypeInfo::GetIDsOfNames(OLECHAR FAR* FAR* names, int count)
{
ITypeInfo *pMyTypeInfo = GetI(this);
if (pMyTypeInfo==NULL) return NULL;
MEMBERID *ids = new MEMBERID[count];
SCODE sc = pMyTypeInfo->GetIDsOfNames(names, count, ids);
if (FAILED(sc))
{
delete [] ids;
return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo);
}
PyObject *ret = PyTuple_New(count);
for (int i = 0; i < count; i++)
PyTuple_SetItem(ret, i, PyInt_FromLong(ids[i]));
delete [] ids;
return ret;
}
**********/
PyObject *PyITypeInfo::GetNames(MEMBERID id)
{
BSTR names[256];
unsigned len = 0;
ITypeInfo *pMyTypeInfo = GetI(this);
if (pMyTypeInfo==NULL) return NULL;
PY_INTERFACE_PRECALL;
SCODE sc = pMyTypeInfo->GetNames(id, names, 256, &len);
PY_INTERFACE_POSTCALL;
if (FAILED(sc))
return PyCom_BuildPyException(sc, pMyTypeInfo, IID_ITypeInfo);
PyObject *ret = PyTuple_New(len);
for (unsigned i = 0; i < len; i++)
{
// Again, MAkeBSTRToObj occasionally gives crap at EOS.
PyObject *obString = MakeOLECHARToObj(names[i]);
PyTuple_SetItem(ret, i, obString);
SysFreeString(names[i]);
}
return ret;
}
示例5: rec
BOOL comauto::RecordInfo::IsMatchingType( IRecordInfo *pRecordInfo)
{
BOOL rt = TRUE;
ITypeInfo* otypeinfo = 0;
ITypeInfo* rectypeinfo = 0;
ITypeInfo* orectypeinfo = 0;
TYPEATTR* otypeattr = 0;
VARDESC* vd = 0;
VARDESC* ovd = 0;
BSTR varname = NULL;
BSTR ovarname = NULL;
try
{
WRAP( pRecordInfo->GetTypeInfo( &otypeinfo))
WRAP( otypeinfo->GetTypeAttr( &otypeattr))
if (m_typeattr->guid == otypeattr->guid) goto Cleanup;
if (m_typeattr->cVars != otypeattr->cVars) {rt=FALSE; goto Cleanup;}
unsigned short ii;
for (ii = 0; ii < m_typeattr->cVars; ++ii)
{
if (vd)
{
m_typeinfo->ReleaseVarDesc( vd);
vd = NULL;
}
WRAP( m_typeinfo->GetVarDesc( ii, &vd))
if (ovd)
{
otypeinfo->ReleaseVarDesc( ovd);
ovd = NULL;
}
WRAP( otypeinfo->GetVarDesc( ii, &ovd))
if (vd->elemdescVar.tdesc.vt != ovd->elemdescVar.tdesc.vt || vd->oInst != ovd->oInst)
{
rt=FALSE; goto Cleanup;
}
UINT nn;
if (varname)
{
::SysFreeString( varname); varname = NULL;
}
WRAP( m_typeinfo->GetNames( vd->memid, &varname, 1, &nn))
if (ovarname)
{
::SysFreeString( ovarname); ovarname = NULL;
}
WRAP( otypeinfo->GetNames( ovd->memid, &ovarname, 1, &nn))
if (wcscmp( varname, ovarname) != 0)
{
rt=FALSE; goto Cleanup;
}
if (vd->elemdescVar.tdesc.vt == VT_USERDEFINED)
{
if (rectypeinfo)
{
rectypeinfo->Release();
rectypeinfo = 0;
}
WRAP( m_typeinfo->GetRefTypeInfo( vd->elemdescVar.tdesc.hreftype, &rectypeinfo))
if (orectypeinfo)
{
orectypeinfo->Release();
orectypeinfo = NULL;
}
WRAP( m_typeinfo->GetRefTypeInfo( ovd->elemdescVar.tdesc.hreftype, &orectypeinfo))
comauto::RecordInfo rec( rectypeinfo);
comauto::RecordInfo orec( orectypeinfo);
if (rec.IsMatchingType( &orec) == FALSE)
{
rt=FALSE; goto Cleanup;
}
}
}
}
catch (...)
{
rt = FALSE;
}
Cleanup:
if (vd) m_typeinfo->ReleaseVarDesc( vd);
if (ovd) otypeinfo->ReleaseVarDesc( ovd);
if (otypeattr) otypeinfo->ReleaseTypeAttr( otypeattr);
if (rectypeinfo) rectypeinfo->Release();
if (orectypeinfo) orectypeinfo->Release();
if (otypeinfo) otypeinfo->Release();
if (varname) ::SysFreeString( varname);
if (ovarname) ::SysFreeString( ovarname);
return rt;
}
示例6: InitEvent
STDMETHODIMP ESource::InitEvent(IDispatch *SourceDispatch,
OrxScript *ORexxScript,
FILE *LogFile)
{
ITypeInfo *SourceType;
TYPEATTR *TypeAttributes;
BSTR SourceName;
unsigned int NameCount;
int i;
FUNCDESC *FuncDesc;
char DispIDName[29];
PEMAP NewMap;
HRESULT RetCode=S_OK;
int EMCount;
FPRINTF2(LogFile,"created a new Event Source. %p\n",this);
FPRINTF2(DLLlogfile,"created a new Event Source.%p\n",this);
EventType = AddScriptlet;
Source = SourceDispatch; // Mimick the ParseProcedures "THIS" parameter by returning this pointer.
Engine = ORexxScript;
Connected = false;
ConnectionPoint = NULL;
Container = NULL;
logfile = LogFile;
RetCode = GetTypeInfo(&SourceType);
if (SUCCEEDED(RetCode))
{
RetCode = SourceType->GetTypeAttr(&TypeAttributes);
memcpy(&SourceGUID,&TypeAttributes->guid,sizeof(GUID));
EMCount = TypeAttributes->cFuncs;
SourceType->ReleaseTypeAttr(TypeAttributes);
OLECHAR lGUID[50];
StringFromGUID2(SourceGUID,lGUID,sizeof(lGUID));
FPRINTF2(logfile,"The GUID is %S and there are %d functions.\n",lGUID,EMCount);
/* For each entry in the type library, create an entry on the Event Map chain.
* This is a many to one relation. Each of the different Source Disp ID's
* will translate to the same Sink Disp ID. There is only one chunk of code
* being bound to this Event that the Type Library is describing. So every
* Source call must map to the same Sink.
*/
for (i=0; i<EMCount; i++)
{
SourceType->GetFuncDesc(i, &FuncDesc);
// Despite what the documentation says, this returns Max Names, not Max Names - 1.
// The first name is the function name, the remainder if they exist are parameters.
SourceType->GetNames(FuncDesc->memid, &SourceName, 1, &NameCount);
sprintf(DispIDName,"%d",FuncDesc->memid);
// This creates the entry for the function with an invalid DispID to call.
RetCode = AddMap(DispIDName,&NewMap);
if (FAILED(RetCode)) return RetCode;
FPRINTF2(logfile,"ESource::InitEvent - AddScriptlet \"%S\" \n",SourceName);
NewMap->SourceEventName = SourceName;
SourceType->ReleaseFuncDesc(FuncDesc);
}
SourceType->Release();
}
else
{
FPRINTF2(logfile,"Could not obtain TypInfo for this event! HRESULT %08x\n",RetCode);
}
return RetCode;
}