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 27 28 29 30 31 32 33 34 35 36
|
//IDL
dispinterface _IEngineEvents
{
methods:
[id(1)] HRESULT getFileName([out] BSTR* moduleName);
};
//Code C++
void fire()
{
CComVariant* pVars = new CComVariant[1];
pVars[0] = ::SysAllocString( TEXT("STRING_TEST") );
CComVariant varResult;
int s = m_vec.GetSize();
for (int nConnectionIndex=0;nConnectionIndex<s; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if ( pDispatch )
{
VariantClear(&varResult);
DISPPARAMS disp = { pVars, NULL, size, 0 };
pDispatch->Invoke( 1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
//ICI pVars[0] est tjrs egale à STRING_TEST
}
//Code C#
void _engine_getFileName(out string moduleName) //On a bien le parametre out
{
moduleName = "Hello world";
} |