// Expression.cpp : implémentation de CExpression #include "stdafx.h" #include "Bus.h" #include "Ivy.h" #include "IvyApplication.h" #include "Expression.h" char * ConvBSTR( BSTR str ); BSTR ConvCSTR( const char *str ); // CExpression STDMETHODIMP CExpression::Unbind(void) { if ( !bus ) return E_FAIL; if ( bus->bus ) bus->bus->UnbindMsg( id ); bus->Release(); return S_OK; } void CExpression::OnMessage(IvyApplication * app, int argc, const char ** argv) { BSTR appname = ConvCSTR( app->GetName() ); SAFEARRAY *pArrayVal = NULL; HRESULT hr = S_OK; //Create the safe array for the arguments string. pArrayVal = SafeArrayCreateVector( VT_VARIANT, 0, argc ); if (!(pArrayVal == NULL) ) { // Set the values for each element of the array for( long i = 0 ; i < argc && SUCCEEDED( hr );i++) { hr = SafeArrayPutElement(pArrayVal, &i, new CComVariant(ConvCSTR(argv[i]))); } } VARIANT args; args.vt = VT_ARRAY | VT_VARIANT; args.parray = pArrayVal; Received( appname, args ); SafeArrayDestroy(pArrayVal); } // CExpression CExpression::CExpression() { id = -1; bus = 0; ATLTRACE("CExpression created\n"); } CExpression::~CExpression() { Unbind(); id = -1; bus = 0; ATLTRACE("CExpression destroyed\n"); }