Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microsoft Consumer Channels and Central Marketing Group

Similar presentations


Presentation on theme: "Microsoft Consumer Channels and Central Marketing Group"— Presentation transcript:

1 Microsoft Consumer Channels and Central Marketing Group
4/26/2017 WRL Sridhar Madhugiri, Software Design Engineer Lukasz Chodorski, Software Design Engineer Microsoft Corporation © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

2 Agenda WRL Overview WRL Classes Consuming WinRT Project template Demo
4/26/2017 Agenda WRL Overview WRL Classes Consuming WinRT Mentions these are not in order of importance. Hint of Windows on ARM, but don’t add it as a bullet. Project template Demo © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

3 WRL Overview

4 WRL Template based implementation Consume and Author WinRT objects
4/26/2017 WRL Template based implementation Consume and Author WinRT objects Exception Free Mentions these are not in order of importance. Hint of Windows on ARM, but don’t add it as a bullet. Works at ABI level Developed specifically for WinRT © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

5 Why use WRL Porting COM components to Metro No exceptions requirement
4/26/2017 Why use WRL Porting COM components to Metro No exceptions requirement Interop with Com Mentions these are not in order of importance. Hint of Windows on ARM, but don’t add it as a bullet. No C++ extensions requirement Fine grained control © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

6 WRL Classes

7 Winrt Concepts WinRT Object Delegate Event Misc Reference counted
Implements IInspectable Instantiated through factory WeakReference support Delegate Callback Interface with method Delegate instance is WinRT object Event Delegate used as Event callback Server advertises events Client creates delegate and registers it to receive events Misc Reference count management Asynchronous operations

8 WRL Classes WinRT Object Delegate Event Misc RuntimeClass
InspectableClass ActivatableClass ActivationFactory Delegate Callback Event EventSource Callback Misc ComPtr, WeakPtr AsyncBase And many more

9 Consuming WinRT

10 ComPtr, HString ComPtr<IActivationFactory> activationFactory; HRESULT hr = GetActivationFactory( HString::MakeReference(RuntimeClass_Windows_Foundation_Uri).Get(), &activationFactory ); // Error handling ComPtr<IUriRuntimeClassFactory> uriActivationFactory; hr = activationFactory.As(&uriActivationFactory); ComPtr<IUriRuntimeClass> uri; hr = uriActivationFactory->CreateUri( HString::MakeReference(L" &uri Wrappers::HString domainName; hr = uri->get_Domain(domainName.GetAddressOf());

11 Delegate Callback<ITimerElapsedHandler>(
ComPtr<IThreadPoolTimerStatics> timerFactory;    HRESULT hr = GetActivationFactory( Wrappers::HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPoolTimer).Get(), &timerFactory );        // Error handling TimeSpan delay; delay.Duration = 200; ComPtr<IThreadPoolTimer> timer; hr = timerFactory->CreateTimer( Callback<ITimerElapsedHandler>( [](IThreadPoolTimer* timer) -> HRESULT {               // Perform some action in separate thread               return S_OK;        } ).Get(), delay, &timer

12 WRL Project Template

13 Project template Available in Online template gallery
Select Online/Templates/C++/WRL Class Library in New project dialog Does not work with Beta Template generated files Project file with correct settings IDL file with one interface and one runtimeclass Source files that implement the interface and runtime class Broiler plate code to implement standard exports

14 Default WRL project demo

15 Project files Project settings IDL Module.cpp WRLClassLibrary1.cpp
Preprocessor Define WINAPI_FAMILY=WINAPI_PARTITION_APP MIDL setting to generate WinMD Custom build step for mdmerge IDL namespace runtimeclass, interface exclusiveto, activatable Module.cpp Broilerplate code Wires exports to WRL activation infrastructure WRLClassLibrary1.cpp RuntimeClass Template parameters - interfaces for Object Implements- AddRef, Release, QI, GetIids WeakReference support InspectableClass Implements – GetRuntimeclassName, GetTrustLevel ActivatableClass Associates default Activation factory with class Wires factory to WRL activation infrastructure

16 Add method demo

17 Add Method IDL CPP Add method to interface Implement method in class
__stdcall important

18 Add event demo

19 Add Event IDL CPP Delegate definition – keyword delegate
MIDL creates an interface with method that matches delegate signature Add eventadd and eventremove methods to interface Name of both methods should be same Fixed signature CPP EventSource templated on delegate interface as member of class Add methods corresponding to eventadd and eventremove methods in interface Delegate represented by its interface name eventadd function has add_ prefix and eventremove has remove_ prefix In the implementation of add/remove call Add/Remove on EventSource Invoke event by calling InvokeAll on EventSource

20 Add non default constructor
demo

21 Add Custom Constructor
IDL Define constructor factory interface Add one or more constructor methods, exclusiveto attribute Out/retval parameter type has to match type specified with exclusiveto Specify factory interface as parameter to activatable attribute on runtimeclass CPP Implement RuntimeClassInitialize Two phase construction Default constructor cannot fail Parameters same as the ones on constructor interface method Add factory class Template on Constructor interface Implement constructor interface methods MakeAndInitialize instantiates class & calls RuntimeClassInitialize Use ActivitableClassWithFactory Similar to ActivitableClass

22 Conclusion Fairly easy to use Exceptions cannot cross ABI boundary
4/26/2017 Conclusion Fairly easy to use Exceptions cannot cross ABI boundary Tedious Mentions these are not in order of importance. Hint of Windows on ARM, but don’t add it as a bullet. © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

23 Microsoft Consumer Channels and Central Marketing Group
4/26/2017 © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Download ppt "Microsoft Consumer Channels and Central Marketing Group"

Similar presentations


Ads by Google