--------------------------------------------------------------------------------
-- <auto-generated>                                                           --
--     This code was generated by a tool.                                     --
--                                                                            --
--     Changes to this file may cause incorrect behavior and will be lost if  --
--     the code is regenerated.                                               --
-- </auto-generated>                                                          --
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--                                                                            --
--    Copyright(c) 2018 Alexander Gamper, All Rights Reserved.                --
--                                                                            --
--    Ada-WinRT                                                               --
--                                                                            --
-- This program is free software: you can redistribute it and / or modify     --
-- it under the terms of the GNU Lesser General Public License as published by--
-- the Free Software Foundation, either version 3 of the License, or          --
-- (at your option) any later version.                                        --
--                                                                            --
-- This program is distributed in the hope that it will be useful,            --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of             --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               --
-- GNU Lesser General Public License for more details.                        --
--                                                                            --
-- You should have received a copy of the GNU Lesser General Public License   --
-- along with this program.If not, see http://www.gnu.org/licenses            --
--                                                                            --
--------------------------------------------------------------------------------
with Windows.ApplicationModel.Activation;
with Windows.ApplicationModel.Core;
with Windows.Storage;
with Windows.Storage.Streams;
with Windows.System;
with Ada.Unchecked_Conversion;
--------------------------------------------------------------------------------
package body Windows.ApplicationModel is

   ------------------------------------------------------------------------
   -- Delegates/Events
   ------------------------------------------------------------------------
   
   function Invoke
   (
      This       : access AsyncOperationCompletedHandler_IPackageCatalogAddOptionalPackageResult_Interface
      ; asyncInfo : Windows.ApplicationModel.IAsyncOperation_IPackageCatalogAddOptionalPackageResult
      ; asyncStatus : Windows.Foundation.AsyncStatus
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(asyncInfo, asyncStatus);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access AsyncOperationCompletedHandler_IPackageCatalogRemoveOptionalPackagesResult_Interface
      ; asyncInfo : Windows.ApplicationModel.IAsyncOperation_IPackageCatalogRemoveOptionalPackagesResult
      ; asyncStatus : Windows.Foundation.AsyncStatus
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(asyncInfo, asyncStatus);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access AsyncOperationCompletedHandler_IPackageCatalogRemoveResourcePackagesResult_Interface
      ; asyncInfo : Windows.ApplicationModel.IAsyncOperation_IPackageCatalogRemoveResourcePackagesResult
      ; asyncStatus : Windows.Foundation.AsyncStatus
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(asyncInfo, asyncStatus);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access AsyncOperationCompletedHandler_IPackageContentGroup_Interface
      ; asyncInfo : Windows.ApplicationModel.IAsyncOperation_IPackageContentGroup
      ; asyncStatus : Windows.Foundation.AsyncStatus
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(asyncInfo, asyncStatus);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access AsyncOperationCompletedHandler_IPackageUpdateAvailabilityResult_Interface
      ; asyncInfo : Windows.ApplicationModel.IAsyncOperation_IPackageUpdateAvailabilityResult
      ; asyncStatus : Windows.Foundation.AsyncStatus
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(asyncInfo, asyncStatus);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access AsyncOperationCompletedHandler_IStartupTask_Interface
      ; asyncInfo : Windows.ApplicationModel.IAsyncOperation_IStartupTask
      ; asyncStatus : Windows.Foundation.AsyncStatus
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(asyncInfo, asyncStatus);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access AsyncOperationCompletedHandler_StartupTaskState_Interface
      ; asyncInfo : Windows.ApplicationModel.IAsyncOperation_StartupTaskState
      ; asyncStatus : Windows.Foundation.AsyncStatus
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(asyncInfo, asyncStatus);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access EventHandler_IEnteredBackgroundEventArgs_Interface
      ; sender : Windows.Object
      ; args : Windows.ApplicationModel.IEnteredBackgroundEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(sender, args);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access EventHandler_ILeavingBackgroundEventArgs_Interface
      ; sender : Windows.Object
      ; args : Windows.ApplicationModel.ILeavingBackgroundEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(sender, args);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access EventHandler_ISuspendingEventArgs_Interface
      ; sender : Windows.Object
      ; args : Windows.ApplicationModel.ISuspendingEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(sender, args);
      return Hr;
   end;
   
   function Invoke
   (
      This       : access TypedEventHandler_IPackageCatalog_add_PackageInstalling_Interface
      ; sender : Windows.ApplicationModel.IPackageCatalog
      ; args : Windows.ApplicationModel.IPackageInstallingEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.ApplicationModel.IPackageCatalog(sender), Windows.ApplicationModel.IPackageInstallingEventArgs(args));
      return Hr;
   end;
   
   function Invoke
   (
      This       : access TypedEventHandler_IPackageCatalog_add_PackageStaging_Interface
      ; sender : Windows.ApplicationModel.IPackageCatalog
      ; args : Windows.ApplicationModel.IPackageStagingEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.ApplicationModel.IPackageCatalog(sender), Windows.ApplicationModel.IPackageStagingEventArgs(args));
      return Hr;
   end;
   
   function Invoke
   (
      This       : access TypedEventHandler_IPackageCatalog_add_PackageStatusChanged_Interface
      ; sender : Windows.ApplicationModel.IPackageCatalog
      ; args : Windows.ApplicationModel.IPackageStatusChangedEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.ApplicationModel.IPackageCatalog(sender), Windows.ApplicationModel.IPackageStatusChangedEventArgs(args));
      return Hr;
   end;
   
   function Invoke
   (
      This       : access TypedEventHandler_IPackageCatalog_add_PackageUninstalling_Interface
      ; sender : Windows.ApplicationModel.IPackageCatalog
      ; args : Windows.ApplicationModel.IPackageUninstallingEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.ApplicationModel.IPackageCatalog(sender), Windows.ApplicationModel.IPackageUninstallingEventArgs(args));
      return Hr;
   end;
   
   function Invoke
   (
      This       : access TypedEventHandler_IPackageCatalog_add_PackageUpdating_Interface
      ; sender : Windows.ApplicationModel.IPackageCatalog
      ; args : Windows.ApplicationModel.IPackageUpdatingEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.ApplicationModel.IPackageCatalog(sender), Windows.ApplicationModel.IPackageUpdatingEventArgs(args));
      return Hr;
   end;
   
   function Invoke
   (
      This       : access TypedEventHandler_IPackageCatalog2_add_PackageContentGroupStaging_Interface
      ; sender : Windows.ApplicationModel.IPackageCatalog
      ; args : Windows.ApplicationModel.IPackageContentGroupStagingEventArgs
   )
   return Windows.HRESULT is
      Hr : Windows.HRESULT := S_OK;
   begin
      This.Callback(Windows.ApplicationModel.IPackageCatalog(sender), Windows.ApplicationModel.IPackageContentGroupStagingEventArgs(args));
      return Hr;
   end;
   
   ------------------------------------------------------------------------
   -- Create functions (for activatable classes)
   ------------------------------------------------------------------------
   
   ------------------------------------------------------------------------
   -- Override Implementations
   ------------------------------------------------------------------------
   
   ------------------------------------------------------------------------
   -- Static procedures/functions
   ------------------------------------------------------------------------
   
   function get_Current
   return Windows.ApplicationModel.IAppInfo is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.AppInfo");
      m_Factory     : IAppInfoStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IAppInfo;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IAppInfoStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.get_Current(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function GetFromAppUserModelId
   (
      appUserModelId : Windows.String
   )
   return Windows.ApplicationModel.IAppInfo is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.AppInfo");
      m_Factory     : IAppInfoStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IAppInfo;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IAppInfoStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.GetFromAppUserModelId(appUserModelId, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function GetFromAppUserModelIdForUser
   (
      user : Windows.System.IUser
      ; appUserModelId : Windows.String
   )
   return Windows.ApplicationModel.IAppInfo is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.AppInfo");
      m_Factory     : IAppInfoStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IAppInfo;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IAppInfoStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.GetFromAppUserModelIdForUser(user, appUserModelId, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function FindOrRegisterInstanceForKey
   (
      key : Windows.String
   )
   return Windows.ApplicationModel.IAppInstance is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.AppInstance");
      m_Factory     : IAppInstanceStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IAppInstance;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IAppInstanceStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.FindOrRegisterInstanceForKey(key, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function get_RecommendedInstance
   return Windows.ApplicationModel.IAppInstance is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.AppInstance");
      m_Factory     : IAppInstanceStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IAppInstance;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IAppInstanceStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.get_RecommendedInstance(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function GetActivatedEventArgs
   return Windows.ApplicationModel.Activation.IActivatedEventArgs is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.AppInstance");
      m_Factory     : IAppInstanceStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.Activation.IActivatedEventArgs;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IAppInstanceStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.GetActivatedEventArgs(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function GetInstances
   return Windows.ApplicationModel.IVector_IAppInstance is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.AppInstance");
      m_Factory     : IAppInstanceStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IVector_IAppInstance;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IAppInstanceStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.GetInstances(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   procedure Unregister
   is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.AppInstance");
      m_Factory     : IAppInstanceStatics := null;
      RefCount      : Windows.UInt32 := 0;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IAppInstanceStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.Unregister;
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
   end;
   
   procedure ShowInstalledApplicationsUI
   is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.CameraApplicationManager");
      m_Factory     : ICameraApplicationManagerStatics := null;
      RefCount      : Windows.UInt32 := 0;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_ICameraApplicationManagerStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.ShowInstalledApplicationsUI;
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
   end;
   
   function get_DesignModeEnabled
   return Windows.Boolean is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.DesignMode");
      m_Factory     : IDesignModeStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Boolean;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IDesignModeStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.get_DesignModeEnabled(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function get_DesignMode2Enabled
   return Windows.Boolean is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.DesignMode");
      m_Factory     : IDesignModeStatics2 := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Boolean;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IDesignModeStatics2'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.get_DesignMode2Enabled(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function LaunchFullTrustProcessForAppAsync
   (
      fullTrustPackageRelativeAppId : Windows.String
   )
   return Windows.Foundation.IAsyncAction is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.FullTrustProcessLauncher");
      m_Factory     : IFullTrustProcessLauncherStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Foundation.IAsyncAction;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IFullTrustProcessLauncherStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.LaunchFullTrustProcessForAppAsync(fullTrustPackageRelativeAppId, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function LaunchFullTrustProcessForAppWithParametersAsync
   (
      fullTrustPackageRelativeAppId : Windows.String
      ; parameterGroupId : Windows.String
   )
   return Windows.Foundation.IAsyncAction is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.FullTrustProcessLauncher");
      m_Factory     : IFullTrustProcessLauncherStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Foundation.IAsyncAction;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IFullTrustProcessLauncherStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.LaunchFullTrustProcessForAppWithParametersAsync(fullTrustPackageRelativeAppId, parameterGroupId, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function LaunchFullTrustProcessForCurrentAppAsync
   return Windows.Foundation.IAsyncAction is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.FullTrustProcessLauncher");
      m_Factory     : IFullTrustProcessLauncherStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Foundation.IAsyncAction;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IFullTrustProcessLauncherStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.LaunchFullTrustProcessForCurrentAppAsync(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function LaunchFullTrustProcessForCurrentAppWithParametersAsync
   (
      parameterGroupId : Windows.String
   )
   return Windows.Foundation.IAsyncAction is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.FullTrustProcessLauncher");
      m_Factory     : IFullTrustProcessLauncherStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Foundation.IAsyncAction;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IFullTrustProcessLauncherStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.LaunchFullTrustProcessForCurrentAppWithParametersAsync(parameterGroupId, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function TryUnlockFeature
   (
      featureId : Windows.String
      ; token : Windows.String
      ; attestation : Windows.String
   )
   return Windows.ApplicationModel.ILimitedAccessFeatureRequestResult is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.LimitedAccessFeatures");
      m_Factory     : ILimitedAccessFeaturesStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.ILimitedAccessFeatureRequestResult;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_ILimitedAccessFeaturesStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.TryUnlockFeature(featureId, token, attestation, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function get_Current
   return Windows.ApplicationModel.IPackage is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.Package");
      m_Factory     : IPackageStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IPackage;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IPackageStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.get_Current(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function OpenForCurrentPackage
   return Windows.ApplicationModel.IPackageCatalog is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.PackageCatalog");
      m_Factory     : IPackageCatalogStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IPackageCatalog;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IPackageCatalogStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.OpenForCurrentPackage(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function OpenForCurrentUser
   return Windows.ApplicationModel.IPackageCatalog is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.PackageCatalog");
      m_Factory     : IPackageCatalogStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IPackageCatalog;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IPackageCatalogStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.OpenForCurrentUser(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function get_RequiredGroupName
   return Windows.String is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.PackageContentGroup");
      m_Factory     : IPackageContentGroupStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.String;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IPackageContentGroupStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.get_RequiredGroupName(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function GetAsync
   (
      taskId : Windows.String
   )
   return Windows.ApplicationModel.IAsyncOperation_IStartupTask is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.StartupTask");
      m_Factory     : IStartupTaskStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.ApplicationModel.IAsyncOperation_IStartupTask;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IStartupTaskStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.GetAsync(taskId, RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
   function GetForCurrentPackageAsync
   return Windows.Address is
      Hr            : Windows.HRESULT := S_OK;
      m_hString     : Windows.String := To_String("Windows.ApplicationModel.StartupTask");
      m_Factory     : IStartupTaskStatics := null;
      RefCount      : Windows.UInt32 := 0;
      RetVal        : aliased Windows.Address;
   begin
      Hr := RoGetActivationFactory(m_hString, IID_IStartupTaskStatics'Access , m_Factory'Address);
      if Hr = 0 then
         Hr := m_Factory.GetForCurrentPackageAsync(RetVal'Access);
         RefCount := m_Factory.Release;
      end if;
      Hr := WindowsDeleteString(m_hString);
      return RetVal;
   end;
   
end;
