IDispatch* CreateConnection(LPCTSTR strAddr)
{
#ifdef UNICODE
LPTSTR strAddress = strAddr;
#else
size_t sl = strlen(strAddr);
LPWSTR strAddress = new WCHAR[sl+1];
strAddress[sl] = 0;
mbstowcs(strAddress, strAddr, sl);
#endif

IDispatch* pDispatch = NULL;
bool ok = false;
RDS::IDataspacePtr pDS;
if (SUCCEEDED(pDS.CreateInstance(OLESTR("RDS.DataSpace"))))
{
_variant_t Result;

try
{
Result = pDS->CreateObject(_bstr_t("Component.bizCOM"), _bstr_t(strAddress));
HRESULT hr = Result.pdispVal->QueryInterface(_uuidof(IDispatch), (LPVOID*) &pDispatch);

WriteLog(_T("CreateConnection :: HR = %x, IDispatch = %p"), hr, pDispatch);
}
catch(_com_error& e)
{
WriteLog(_T("CreateConnection :: exception. [%s]"), e.ErrorMessage());
}
}

#ifndef _UNICODE
delete strAddress;
#endif
return pDispatch;
}

virtual bool WINAPI Test()
{
bool ok = false;
try
{
IDispatch *pConn = CreateConnection(m_strTarget);

if(pConn != 
Read More