Code: Select all
wxAutomationObject *ado = new wxAutomationObject;
wxAutomationObject cnn;
wxString cnnString = "Provider=MSDASQL.1;Mode=Read;Extended Properties='DRIVER=SQL Server;SERVER=(local);UID=User;PWD=****;APP=some_app;WSID=name'";
HRESULT hrADO;
const CLSID CLSID_ADO = {0x00000514,0x0000,0x0010,{0x80,0x00,0x00,0xAA,0x00,0x6D,0x2E,0xA4}};
CoInitialize(NULL);
IDispatch* pDispatchADO;
hrADO = CoCreateInstance(CLSID_ADO, NULL,CLSCTX_INPROC_SERVER, IID_IDispatch, (void**)&pDispatchADO);
if ( SUCCEEDED ( hrADO ) )
{
wxMessageBox (_T("CoCreateInstance ADO OK!!"));
}
else
{
wxLogError(_T("Error code = %08X"), hrADO);
}
ado->SetDispatchPtr(pDispatchADO);
ado->CallMethod("open", cnnString);
Now I have problem. How to get an existing instance of a COM object. The COM object is created by another aplicattion.
In VB it's like: cnn=GetAdoConnection() and thats all.
Is there any method similar to: CoCreateInstance - but not to Create, but to Get ???