示例#1
0
/***************************************************************************************
 *  Method:
 *
 *
 *  Purpose:
 *
 *
 *  Parameters: 
 *
 *
 *  Return value:
 *
 *
 *  Notes:
 *
 ***************************************************************************************/
STDAPI DllRegisterServer()
{    
    HRESULT hr = S_OK;
    char  rcModule[_MAX_PATH];  
    const COCLASS_REGISTER *pCoClass;   

    
    DllUnregisterServer();
    GetModuleFileNameA( GetModuleInst(), rcModule, NumItems( rcModule ) );

    // for each item in the coclass list, register it
    for ( pCoClass = g_CoClasses; (SUCCEEDED( hr ) && (pCoClass->pClsid != NULL)); pCoClass++ )
    {
        // register the class with default values
        hr = REGUTIL::RegisterCOMClass( *pCoClass->pClsid, 
                                        g_szCoclassDesc, 
                                        g_szProgIDPrefix,
                                        g_iVersion, 
                                        pCoClass->szProgID, 
                                        g_szThreadingModel, 
                                        rcModule );                 
    } // for


    if ( FAILED( hr ) )
        DllUnregisterServer();
    
       
    return hr;
    
} // DllRegisterServer
示例#2
0
STDAPI InternalDllGetClassObject(
    REFCLSID rclsid,
    REFIID riid,
    LPVOID FAR *ppv)
{
    // @todo: this is called before the runtime is really started, so the contract's don't work.
    STATIC_CONTRACT_NOTHROW;
    STATIC_CONTRACT_SO_TOLERANT;

    HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
    BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(return COR_E_STACKOVERFLOW);


    if (rclsid == CLSID_CorMetaDataDispenser || rclsid == CLSID_CorMetaDataDispenserRuntime ||
        rclsid == CLSID_CorRuntimeHost || rclsid == CLSID_CLRRuntimeHost ||
        rclsid == CLSID_TypeNameFactory
#ifdef FEATURE_HOSTED_BINDER
        || rclsid == __uuidof(CLRPrivRuntime)
#endif
       )
    {
        hr = MetaDataDllGetClassObject(rclsid, riid, ppv);
    }
#ifdef FEATURE_PROFAPI_ATTACH_DETACH
    else if (rclsid == CLSID_CLRProfiling)
    {
        hr = ICLRProfilingGetClassObject(rclsid, riid, ppv);
    }
#endif // FEATURE_PROFAPI_ATTACH_DETACH
#ifdef FEATURE_COMINTEROP
    else if (rclsid == CLSID_ComCallUnmarshal || rclsid == CLSID_ComCallUnmarshalV4)
    {
        // We still respond to the 1.0/1.1/2.0 CLSID so we don't break anyone who is instantiating
        // this (we could be called for CLSID_ComCallUnmarshal if the process is rollForward=true)
        hr = g_COMCallUnmarshal.QueryInterface(riid, ppv);
    }
    else if (rclsid == CLSID_CorSymBinder_SxS)
    {
        EX_TRY
        {

            // PDB format - use diasymreader.dll with COM activation
            InlineSString<_MAX_PATH> ssBuf;
            if (SUCCEEDED(GetHModuleDirectory(GetModuleInst(), ssBuf)))
            {
                hr = FakeCoCallDllGetClassObject(rclsid,
                    ssBuf,
                    riid,
                    ppv,
                    NULL
                    );
            }
        }
        EX_CATCH_HRESULT(hr);
    }