Задайте вопросЗадайте вопрос
 

ОтвеченоCoCreateInstance returns REGDB_E_CLASSNOTREG (IMAPI)

  • 5 сентября 2006 г. 14:36Alx_it Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     
    Hi, i'm trying to accessing IMAPI from a Managed C++ Windows Form Control Library

    the problem is that when i call CoCreateInstance  i get in return REGDB_E_CLASSNOTREG.
    I Really dont understand why since the equivalent code from a .NET imapi wrapper that works is identical. notice also that the same C++ code here works on another machine.
    i assume also that the class is correctly registered since the C# code works.
    thanks to anyone who try to help

    My C++/CLI code:
    [code]
    CLSIDFromString(L"{520CCA62-51A5-11D3-9144-00104BA11C5E}", &CLSID_MSDiscMasterObj);
    CLSIDFromString(L"{520CCA62-51A5-11D3-9144-00104BA11C5E}", &IID_IDiscMaster);

    CoInitialize( NULL );

    hr = CoCreateInstance(CLSID_MSDiscMasterObj, nullptr, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IDiscMaster, (void**)&m_pDiscMaster); //REGDB_E_CLASSNOTREG
    [/code]


    working C# code
    [code]
    object discMaster = null;
    Guid clsIdDiscMaster = new Guid(CLSID_MSDiscMasterObj);
    Guid iidDiscMaster = new Guid(IID_IDiscMaster);
    int hResult = IMAPIObjectFactory.CoCreateInstance(ref clsIdDiscMaster, IntPtr.Zero, CLSCTX.CLSCTX_INPROC_SERVER | CLSCTX.CLSCTX_LOCAL_SERVER, ref iidDiscMaster, out discMaster);
    [/code]

    where CoCreateInstance is
    [code]
            [DllImport("ole32", CharSet = CharSet.Unicode)]
            private extern static int CoCreateInstance(
                ref Guid CLSID,
                IntPtr pUnkOuter,
                CLSCTX dwClsContext,
                ref Guid IID,
                [MarshalAs(UnmanagedType.Interface)]
                out object ppv);
    [/code]

Ответы

Все ответы