locked
How to call COM inetrface in metro app?

    Question

  • I have a COM component, i want to use it in my metro app.

    this is my code:

    	ComPtr<IMyEngine> spFactory;
    
    	HRESULT hr = CoCreateInstance(CLSID_MyEngine, nullptr, CLSCTX_INPROC_SERVER, IID_IMyEngine, &spFactory);

    after return back from CoCreateInstance:

    hr REGDB_E_CLASSNOTREG 0x80040154 Class not registered HRESULT

    But in my win32 test app, it can work.

    Does somebody know why?


    haha

    Friday, March 16, 2012 3:01 AM

Answers

All replies

  • how to call COM interface in metro app? I am eager to know the answer. maybe CoCreateInstance is not available in metro?
    Friday, March 16, 2012 2:20 PM
  • Metro style apps cannot read the registry and so cannot load registered COM objects. You will need to include the object's DLL in your package and load it via registration free COM.

    See Creating Registration-free COM objects and Simplify App Deployment with ClickOnce and Registration-Free COM (this targets older platforms, but should give the general idea of what you need to do).

    --Rob

    Friday, March 16, 2012 7:27 PM
    Owner
  • Thanks, i'll try it.

    haha

    Monday, March 19, 2012 9:55 AM
  • Hello Rob,

    I want to call COM object in metro app.

    I have read Reg-free documents.

    I use CoCreateInstanceFromApp() in my metro app.

    But, I don't know how to add my COM dll to my project.

    In addition, I don't know how to modify the manifest.

    any sample codes?

    Thanks

    Tuesday, May 8, 2012 8:28 AM