locked
IUnknown IDispatch IConnectionPoint ITypeLib

    Question

  • Do the objects in WinRT support IUnknown, IDispatch and IConnectionPoint?

    How do I get something like an ITypeLib from the metadata?

    Is there a way to create WinRT objects without the new C++ extensions?

    Wednesday, September 14, 2011 8:12 AM

Answers

  • All WinRT objects in the WinRT support IUnknown, because that's how we manage their reference count and get to methods with QueryInterface. But for most developers of Metro style applications, they won't need to deal with IUnknown because the language projections will automatically call IUnknown for you.

    WinRT objects don't need IDispatch - because all WinRT languages talk directly to the WinRT type system - making JavaScript and other scripting languages a first-class citizen of this new platform ecosystem. 

    They also don't need IConnectionPointContainer et al - because WinRT objects natively support an event pattern, which will show up in a natural and familiar way in each language as events.

    It is possible to create WinRT objects without the new C++ extensions, though it's less easy to do so. There is a template library called WRL (which is included with the Developer Preview build) that makes it somewhat easier. I recommend trying out the C++ extensions first - the C++ team have done a great job of making these WinRT objects feel natural.

    Finally, we do have some limited support for using COM from C++ within a Metro style app, which should help you re-use existing COM objects (including those that use IDispatch and IConnectionPointContainer). You'll need to use a modified form of reg-free COM manifest to declare the object within your App. This support doesn't currently include TypeLibs.

     


    Martyn Lovell
    Development Manager
    Windows Runtime Experience
    martynl@microsoft.com
    Wednesday, September 14, 2011 5:43 PM

All replies

  • All WinRT objects in the WinRT support IUnknown, because that's how we manage their reference count and get to methods with QueryInterface. But for most developers of Metro style applications, they won't need to deal with IUnknown because the language projections will automatically call IUnknown for you.

    WinRT objects don't need IDispatch - because all WinRT languages talk directly to the WinRT type system - making JavaScript and other scripting languages a first-class citizen of this new platform ecosystem. 

    They also don't need IConnectionPointContainer et al - because WinRT objects natively support an event pattern, which will show up in a natural and familiar way in each language as events.

    It is possible to create WinRT objects without the new C++ extensions, though it's less easy to do so. There is a template library called WRL (which is included with the Developer Preview build) that makes it somewhat easier. I recommend trying out the C++ extensions first - the C++ team have done a great job of making these WinRT objects feel natural.

    Finally, we do have some limited support for using COM from C++ within a Metro style app, which should help you re-use existing COM objects (including those that use IDispatch and IConnectionPointContainer). You'll need to use a modified form of reg-free COM manifest to declare the object within your App. This support doesn't currently include TypeLibs.

     


    Martyn Lovell
    Development Manager
    Windows Runtime Experience
    martynl@microsoft.com
    Wednesday, September 14, 2011 5:43 PM
  • Hi,

     

    It is nice to know that we could use COM in C++ to build Metro APP. Once I provide the manifest of that COM, I could use CoCreateInstance, those Win32 functions to work? If I only register COM component in Win32 environment, can WinRT recongnize it?

    Thanks.

     

    Alex

    Thursday, September 15, 2011 11:44 PM
  • There is a new important interface with WinRT: IInspectable.

    Like IDispatch allows to use COM classes from scripts, IInspectable allows to use WinRT components from supported languages.

    Tuesday, October 4, 2011 10:00 AM
  • Could you please could provide a link for more info on how to use "reg-free COM manifest to declare the object within your App" for Metro or a custom WinRT component?

    Thank you

    Wednesday, November 30, 2011 2:01 AM