ATS
2005-01-05 21:03:07 UTC
Please help,
I'm trying to make a C++ class wrap COM and deal with "optional" parameters.
To do this, I need to know how many parameters a method has. Through
IDispatch/ATL I found this:
CComPtr<ITypeInfo> pITypeInfo;
HRESULT_Ret = pIDispatch->GetTypeInfo(0, LOCALE_USER_DEFAULT, &pITypeInfo);
if (HRESULT_Ret == S_OK)
{
FUNCDESC *pFUNCDESC;
UINT ui = 2; // Matched the DISPID I got from GetIDsOfNames for my method.
HRESULT_Ret = pITypeInfo->GetFuncDesc(ui, &pFUNCDESC);
if (HRESULT_Ret == S_OK)
{
uiArgsRequired = (UINT) pFUNCDESC->cParams;
pITypeInfo->ReleaseFuncDesc(pFUNCDESC);
}
}
But the "cParams" being returned for my ATL method comes back as "3" where
it should be 5 as it is declared as such:
[id(2), helpstring("method MyMethod")] HRESULT MyMethod([in] VARIANT
varParam1, [in] VARIANT varParam2, [in] VARIANT varParam3, [in] VARIANT
vaParam4, [in] VARIANT varParam5, [out,retval] BSTR* pBSTR_Ret);
I've tried setting "ui" to be 2 - 1. I've also tried using GetTypeAttr and
the "pTYPEATTR->cFuncs" to set ui as ui = pTYPEATTR->cFuncs - 2, and ui = 2 -
1, and ui = pTYPEATTR->cFuncs - 2 - 1; Bottom line, it is not working, and I
can not find any rules what "ui" should be "REALLY" set to other than the
documentation for "GetFuncDesc", which says this:
-------------------------------
HRESULT GetFuncDesc(
unsigned int index,
FUNCDESC FAR* FAR* ppFuncDesc
);
index
Index of the function whose description is to be returned. The index
should be in the range of 0 to 1 less than the number of functions in this
type.
-------------------------
What should I do?
I'm trying to make a C++ class wrap COM and deal with "optional" parameters.
To do this, I need to know how many parameters a method has. Through
IDispatch/ATL I found this:
CComPtr<ITypeInfo> pITypeInfo;
HRESULT_Ret = pIDispatch->GetTypeInfo(0, LOCALE_USER_DEFAULT, &pITypeInfo);
if (HRESULT_Ret == S_OK)
{
FUNCDESC *pFUNCDESC;
UINT ui = 2; // Matched the DISPID I got from GetIDsOfNames for my method.
HRESULT_Ret = pITypeInfo->GetFuncDesc(ui, &pFUNCDESC);
if (HRESULT_Ret == S_OK)
{
uiArgsRequired = (UINT) pFUNCDESC->cParams;
pITypeInfo->ReleaseFuncDesc(pFUNCDESC);
}
}
But the "cParams" being returned for my ATL method comes back as "3" where
it should be 5 as it is declared as such:
[id(2), helpstring("method MyMethod")] HRESULT MyMethod([in] VARIANT
varParam1, [in] VARIANT varParam2, [in] VARIANT varParam3, [in] VARIANT
vaParam4, [in] VARIANT varParam5, [out,retval] BSTR* pBSTR_Ret);
I've tried setting "ui" to be 2 - 1. I've also tried using GetTypeAttr and
the "pTYPEATTR->cFuncs" to set ui as ui = pTYPEATTR->cFuncs - 2, and ui = 2 -
1, and ui = pTYPEATTR->cFuncs - 2 - 1; Bottom line, it is not working, and I
can not find any rules what "ui" should be "REALLY" set to other than the
documentation for "GetFuncDesc", which says this:
-------------------------------
HRESULT GetFuncDesc(
unsigned int index,
FUNCDESC FAR* FAR* ppFuncDesc
);
index
Index of the function whose description is to be returned. The index
should be in the range of 0 to 1 less than the number of functions in this
type.
-------------------------
What should I do?