コード例 #1
0
ファイル: cam_ascomlate.cpp プロジェクト: goodwink/phd2
bool Camera_ASCOMLateClass::Create(DispatchObj *obj, DispatchClass *cls)
{
    IDispatch *idisp = m_gitEntry.Get();
    if (idisp)
    {
        obj->Attach(idisp, cls);
        return true;
    }

    BSTR bstr_progid;
    if (!GetDriverProgId(&bstr_progid, m_choice))
        return false;

    if (!obj->Create(bstr_progid))
    {
        Debug.AddLine("ASCOM Camera: Could not get CLSID for camera " + m_choice);
        return false;
    }

    m_gitEntry.Register(*obj);
    return true;
}
コード例 #2
0
ファイル: scope_ascom.cpp プロジェクト: rwg0/phd2
bool ScopeASCOM::Create(DispatchObj& obj)
{
    try
    {
        // is there already an instance registered in the global interface table?
        IDispatch *idisp = m_gitEntry.Get();
        if (idisp)
        {
            obj.Attach(idisp, NULL);
            return true;
        }

        BSTR bstr_progid;
        if (!GetDriverProgId(&bstr_progid, m_choice))
        {
            throw ERROR_INFO("ASCOM Scope: Chooser returned an error");
        }

        if (!obj.Create(bstr_progid))
        {
            throw ERROR_INFO("Could not establish instance of " + wxString(bstr_progid));
        }

        Debug.AddLine(wxString::Format("pScopeDriver = 0x%p", obj.IDisp()));

        // store the driver interface in the global table for access by other threads
        m_gitEntry.Register(obj);
    }
    catch (const wxString& msg)
    {
        Debug.Write(msg + "\n");
        return false;
    }

    return true;
}