HRESULT DDEService::Start()
{
    HRESULT hr = E_FAIL;

    // If m_dwDDEInst is not NULL, then we have already been started, just
    // return S_FALSE which will still pass SUCCEEDED()
    if (!m_dwDDEInst)
    {
        if (FindWindow(_T("Progman"), NULL) == NULL)
        {
            m_hStartEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

            m_hThread = LSCreateThread(
                            "DDEService", _DDEThreadProc, this, &m_idThread);

            WaitForSingleObject(m_hStartEvent, INFINITE);
            CloseHandle(m_hStartEvent);
            hr = S_OK;
        }
    }
    else
    {
        hr = S_FALSE;
    }

    return hr;
}
Example #2
0
void StartupRunner::Run(BOOL bForce)
{
    CloseHandle(LSCreateThread("StartupRunner",
        StartupRunner::_ThreadProc, (LPVOID)(INT_PTR)bForce, NULL));
}