bool getApplication(LPDISPATCH * pVal)
{
	LPDISPATCH pDispatch = acedGetAcadWinApp()->GetIDispatch(TRUE);
	if (pDispatch == NULL)
		return false;
	*pVal = pDispatch;
	return true;
}
예제 #2
0
bool AddSupportPath( const CString& arxPath )
{
    AutoCAD::IAcadPreferences* pPrefer;
    AutoCAD::IAcadPreferencesFiles* pPreferFiles;
    HRESULT hr = NOERROR;

    bool ret = true;
    TRY
    {
        LPDISPATCH pAcadDisp = acedGetAcadWinApp()->GetIDispatch( TRUE );
        AutoCAD::IAcadApplication* pAcad = NULL;
        if ( SUCCEEDED( pAcadDisp->QueryInterface( AutoCAD::IID_IAcadApplication, ( void** )&pAcad ) ) )
        {
            BSTR supportPath;
            hr = pAcad->get_Preferences( &pPrefer );
            pAcad->Release();

            hr = pPrefer->get_Files( &pPreferFiles );
            pPrefer->Release();

            hr = pPreferFiles->get_SupportPath( &supportPath );
            CString stemp = supportPath;
            if( !IsPathExit( stemp, arxPath ) )
            {
                stemp = stemp + _T( ";" ) + arxPath;
                supportPath = stemp.AllocSysString();
                pPreferFiles->put_SupportPath( supportPath );
            }
            SysFreeString( supportPath ); // 用完释放
        }
        pPreferFiles->Release();
    }
    CATCH( COleDispatchException, e )
    {
        //e->ReportError(); // 调试用
        e->Delete();
        ret = false;
    }