Example #1
1
HRESULT CMObject::CreateObject(LPCTSTR objName)
{
	HRESULT hr;
	IDispatchPtr tmpobj;
	Release();
#ifdef _UNICODE
	hr=tmpobj.CreateInstance( (LPOLESTR)objName);
#else
	hr=tmpobj.CreateInstance((LPCSTR)objName);
#endif
	if (SUCCEEDED(hr))
		p=tmpobj.Detach();
	return hr;
}
Example #2
1
HRESULT CMObject::CreateObject(const CLSID clsid)
{
	HRESULT hr;
	IDispatchPtr tmpobj;
	Release();
	hr=tmpobj.CreateInstance(clsid);
	if (SUCCEEDED(hr))
		p=tmpobj.Detach();
	return hr;

}
Example #3
1
_bstr_t RunMatlab( char* strMFile )
{
	CoInitialize(NULL);

	_bstr_t ret;
	//ensure the smarter pointer is destroyed before CoUninitialize
	{
		IDispatchPtr spDisp;
		spDisp.CreateInstance( "Matlab.Application.Single" );

		DIMLAppPtr spMatlabApp;
		spDisp.QueryInterface( __uuidof(spDisp), &spMatlabApp );	
		spDisp = NULL;

		spMatlabApp->Execute( _bstr_t("rand(seed, 999)") );
		ret = spMatlabApp->Execute( _bstr_t(strMFile) );
	}

	CoUninitialize();

	return ret;
}