locked
RegisterActiveObject problem in Win 8 RRS feed

  • Question


  • I have over a dozen LocalServer32 OLE /Automation  apps that are failing to run on multiple machines  in windows 8. This started AFTER the Windows 8 official release. Everything was OK before that, ran fine on Win8 Beta. I've traced the problem down to this OLE function:

    RegisterActiveObject(g_pApplication, CLSID_ICAPSAp, ACTIVEOBJECT_STRONG, pdwObject);

    It returns S_OK and its supposed to QueryInterface with the object class id in order to AddRef, but it never does, causing the app to delete itself.

    What's up?
    Tuesday, December 18, 2012 3:57 PM

Answers

  • RegisterActiveObject is not supported in Windows Store apps. Windows Store apps cannot load arbitrary COM objects, only a few specifically allowed system COM objects and registration free objects included in the app package.

    If you are trying to do this in a desktop app then please post in the desktop app development forums.

    --Rob

    • Marked as answer by Jesse Jiang Thursday, December 20, 2012 2:28 AM
    Tuesday, December 18, 2012 5:42 PM
    Moderator

All replies

  • Here is the code. This appears to be a Microsoft issue in released version of Win8, can anyone from MS respond please?

    Windows 8 OLE Automation fails

    I can’t get OLE Automation DLLs to run on Windows 8. Initialization code is as follows

    The OLE Class Factory doesn’t query interface and addref as required.

    BOOL InitAutomation(HINSTANCE hInst, HWND MainhWnd, DWORD *pdwCF, DWORD *pdwObject,BOOL pl)

    {

    HRESULT hr = S_OK;

    LPCLASSFACTORY pcf = NULL;

    //__asm { int 3};

     

              if(!OLEinit){

                            hr = OleInitialize(NULL);

                            if(FAILED(hr))

                                        return(FALSE);

                            else{

                                        OLEinit = 1;

                                        hr = CApplication::Create(hInst, MainhWnd,&g_pApplication);      

                                        if (FAILED(hr))

                                                    return(FALSE);

     

                                        pcf = new CApplicationCF();

                                        if (!pcf)

                                                    return(FALSE);

                                        pcf->AddRef();          

                                        hr = CoRegisterClassObject(CLSID_ICAPSAp, pcf,

                                                                             CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE,

                                                                             pdwCF);

                                        if (hr != NOERROR){

                                                    pcf->Release();

                                                    return(FALSE);

                                        }

                                        pcf->Release();

     

                                        hr=RegisterActiveObject(g_pApplication, CLSID_ICAPSAp, ACTIVEOBJECT_STRONG, pdwObject);

                                        if(hr != S_OK) {

                                                    return(FALSE);

                                        }

     

     

                            }

                }

                if(pl){

                            return(FALSE);

                }

                else{

                            return(TRUE);

                }

    }

    Tuesday, December 18, 2012 5:30 PM
  • RegisterActiveObject is not supported in Windows Store apps. Windows Store apps cannot load arbitrary COM objects, only a few specifically allowed system COM objects and registration free objects included in the app package.

    If you are trying to do this in a desktop app then please post in the desktop app development forums.

    --Rob

    • Marked as answer by Jesse Jiang Thursday, December 20, 2012 2:28 AM
    Tuesday, December 18, 2012 5:42 PM
    Moderator
  • OK, I was sent here by MS support, I will try the desktop app forums!

    Tuesday, December 18, 2012 7:12 PM