STARTUPINFO si;
PROCESS_INFORMATION pi;
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpTitle = NULL;
si.lpDesktop = NULL;
si.dwX = si.dwY = si.dwYSize = si.dwXSize = 0;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
si.lpReserved2 = NULL;
si.cbReserved2 = 0;
BOOL ret = CreateProcess(strHostFileFullName, NULL, NULL, NULL, FALSE, 0, NULL, strPath, &si, &pi);
if (!ret) {
return false;
}
WaitForInputIdle(pi.hProcess, 30000);
XXXCtxActivator activator;
if(!activator.IsActivated())
return false;
CComPtr<IClassFactory> pFactory;
HRESULT hr = CoGetClassObject(CLSID_XXX, CLSCTX_LOCAL_SERVER, NULL, __uuidof(pFactory), reinterpret_cast<void**>(&pFactory));
if (FAILED(hr))
return false;
CComPtr<IXXX> s_spXXX;
hr = pFactory->CreateInstance(NULL, __uuidof(*s_spXXX), reinterpret_cast<void**>(&s_spXXX));
if(FAILED(hr))
return false;
// If created successfully, start the monitoring thread
DWORD dwProcessId = GetCurrentProcessId();
long nMonitoringPid = 0;
hr = s_spXXX->StartProcessManagementThread(dwProcessId, &nMonitoringPid);
if (FAILED(hr) || nMonitoringPid == 0)
return false;