void StartAndInject(char* cl) { GetStartupInfoW(&si); RotateLogs(); StartServerProcess(cl, &si, &pi); }
void StartAndInject(char* cl) { ZeroMemory(&si,sizeof(si)); si.cb = sizeof(si); RotateLogs(); StartServerProcess(cl, &si, &pi); }
XnStatus XnSensorClient::InitImpl(const XnDeviceConfig* pDeviceConfig) { XnStatus nRetVal = XN_STATUS_OK; XN_MUTEX_HANDLE hServerRunningMutex = NULL; XnOSEvent serverRunningEvent; nRetVal = serverRunningEvent.Open(XN_SENSOR_SERVER_RUNNING_EVENT_NAME); if (nRetVal != XN_STATUS_OK) { nRetVal = serverRunningEvent.Create(XN_SENSOR_SERVER_RUNNING_EVENT_NAME, TRUE); if (nRetVal != XN_STATUS_OK) { xnLogError(XN_MASK_SENSOR_CLIENT, "Failed to create server running event: %s", xnGetStatusString(nRetVal)); return nRetVal; } } nRetVal = xnOSCreateNamedMutex(&hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_NAME); XN_IS_STATUS_OK(nRetVal); nRetVal = xnOSLockMutex(hServerRunningMutex, XN_SENSOR_SERVER_RUNNING_MUTEX_TIMEOUT); if (nRetVal != XN_STATUS_OK) { xnOSCloseMutex(&hServerRunningMutex); return nRetVal; } XnBool bServerRunning = (serverRunningEvent.Wait(1) == XN_STATUS_OK); nRetVal = xnOSUnLockMutex(hServerRunningMutex); xnOSCloseMutex(&hServerRunningMutex); XN_IS_STATUS_OK(nRetVal); if (!bServerRunning) { nRetVal = StartServerProcess(); if (nRetVal != XN_STATUS_OK) { xnLogError(XN_MASK_SENSOR_CLIENT, "Failed to start server process: %s", xnGetStatusString(nRetVal)); return nRetVal; } } nRetVal = serverRunningEvent.Wait(XN_SENSOR_CLIENT_WAIT_FOR_SERVER); if (nRetVal != XN_STATUS_OK) { xnLogError(XN_MASK_SENSOR_CLIENT, "Failed to wait for server to start: %s", xnGetStatusString(nRetVal)); return nRetVal; } // init network nRetVal = xnOSInitNetwork(); XN_IS_STATUS_OK(nRetVal); nRetVal = xnOSCreateCriticalSection(&m_hLock); XN_IS_STATUS_OK(nRetVal); // now init nRetVal = XnStreamReaderDevice::InitImpl(pDeviceConfig); if (nRetVal != XN_STATUS_OK) { xnOSCloseCriticalSection(&m_hLock); return nRetVal; } m_bConnected = TRUE; nRetVal = xnOSCreateEvent(&m_hReplyEvent, FALSE); if (nRetVal != XN_STATUS_OK) { xnOSCloseCriticalSection(&m_hLock); return nRetVal; } nRetVal = xnOSCreateThread(ListenThread, this, &m_hListenThread); if (nRetVal != XN_STATUS_OK) { xnOSCloseEvent(&m_hReplyEvent); xnOSCloseCriticalSection(&m_hLock); return nRetVal; } return (XN_STATUS_OK); }