Windows Embedded CE6 R3 released including Silverlight for Windows Embedded

The project I've been working on since my last blog posts has finally been released!  There is some fantastic documentation out on MSDN that can get you familiar with the new Silverlight for Windows Embedded API and how to create applications: Silverlight for Windows Embedded on MSDN

The first thing you might wonder is how to create an application that uses this new api.  There's an MSDN page for that: https://msdn.microsoft.com/en-us/library/ee503558.aspx, but I thought I would start out by showing some code that I've used when creating applications.  This uses all the functions detailed on MSDN.

 INT WINAPI WinMain(
     HINSTANCE hInstance, 
     HINSTANCE hPrevInstance, 
     LPWSTR lpCmdLine, 
     int nCmdShow
     )
 {
     int             exitCode = -1;
     HRESULT         hr = S_OK;
  
     XamlRuntimeManager xr;
  
     if(xr.IsInitialized())
     {
         if(SUCCEEDED(DoSomethingHere(lpCmdLine)))
         {
             exitCode = 0;
         }
     }
  
     return exitCode;
 }
  

The main thing to notice here is the XamlRuntimeManager, this does all the initilization for you.  Lets take a look at what that class does.

 //this class will initialize and uninitialize XamlRuntime
 //
 class XamlRuntimeManager
 {
 private:
     BOOL m_IsInitialized;
  
 public:
     XamlRuntimeManager()
     {
         m_IsInitialized = XamlRuntimeInitialize();
     }
  
     ~XamlRuntimeManager()
     {
         if(m_IsInitialized)
         {
             XamlRuntimeUninitialize();
         }
     }
  
     BOOL IsInitialized() { return m_IsInitialized; }
  
 };
  

If you want to see this code in action it is in one of the sample applications that has shipped with R3, XamlPerf.