[VCPP.NET 2003] ActiveX et API sans MFC
Bonjour,
J'ai écrit un petit prog qui load un ocx que j'ai également écrit.
Cet Ocx contient notament la fonction suivante:
Code:
VARIANT_BOOL CConversAPICtrl::TstDbl_bool(DOUBLE* pInDouble)
ensuite dans mon application appelante je me link à mon ocx et j'appel ma fonction comme suit:
Code:
1 2 3 4 5 6 7 8 9 10
|
VARIANT aVarParams[1];
for(int i = 0; i < 1; i++)
VariantInit(&aVarParams[i]);
aVarParams[0].vt = VT_R8;
aVarParams[0].dblVal = 653220;
if(FAILED(InvokeMethod(g_pConversAPI, L"TstDbl_bool", aVarParams, 1, NULL)))
cerr<< "Error TstDbl_bool failed !"<<endl; |
sachant que InvokeMethode est écrit comme suit:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| HRESULT InvokeMethod(IDispatch* pDispatch, DISPID methodid, VARIANT aVarParams[],
int nParamCount, VARIANT* pVarRes)
{
// paramètres de l'appel à Invoke (ordre des paramètres inversé)
VARIANTARG* rgvarg = NULL;
if(nParamCount > 0)
{
rgvarg = new VARIANTARG[nParamCount];
for(int i = 0; i < nParamCount; i++)
rgvarg[nParamCount-i-1] = aVarParams[i];
}
// initialisation structure DISPPARAMS;
DISPPARAMS dispparams = {rgvarg, NULL, nParamCount, 0};
// appel de Invoke
HRESULT hr = pDispatch->Invoke(methodid, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, &dispparams, pVarRes, NULL, NULL);
// libération mémoire
if(nParamCount > 0)
delete[] rgvarg;
// retour
return hr;
} |
le problème se situe au return de pDispatch->Invoke il me renvoi Type Mismatch ?
Quelqu'un aurait une idée sur ce problème
merci d'avance