• UWP 检查是否试用版模式


    //老版本的方法:
             // var check=  CurrentAppSimulator.LicenseInformation.IsActive && CurrentAppSimulator.LicenseInformation.IsTrial;
            private StoreContext context = null;
            private StoreAppLicense appLicense = null;
    
            // Call this while your app is initializing.
            private async void InitializeLicense()
            {
                if (context == null)
                {
                    context = StoreContext.GetDefault();
                    // If your app is a desktop app that uses the Desktop Bridge, you
                    // may need additional code to configure the StoreContext object.
                    // For more info, see https://aka.ms/storecontext-for-desktop.
                }
    
                workingProgressRing.IsActive = true;
                appLicense = await context.GetAppLicenseAsync();
                workingProgressRing.IsActive = false;
    
                // Register for the licenced changed event.
                context.OfflineLicensesChanged += context_OfflineLicensesChanged;
    
              
                if ( appLicense.IsTrial)
                {
                    textBlock.Text = $"This is the trial version. Expiration date: {appLicense.ExpirationDate}";
    
                    // Show the features that are available during trial only.
                }
                else
                {
                    // Show the features that are available only with a full license.
                }
            }
    
            private async void context_OfflineLicensesChanged(StoreContext sender, object args)
            {
                // Reload the license.
                workingProgressRing.IsActive = true;
                appLicense = await context.GetAppLicenseAsync();
                workingProgressRing.IsActive = false;
    
                if (appLicense.IsActive)
                {
                    if (appLicense.IsTrial)
                    {
                        textBlock.Text = $"This is the trial version. Expiration date: {appLicense.ExpirationDate}";
    
                        // Show the features that are available during trial only.
                    }
                    else
                    {
                        // Show the features that are available only with a full license.
                    }
                }
            }
    

      

    参考官方:https://docs.microsoft.com/en-us/windows/uwp/monetize/in-app-purchases-and-trials#implement-trial

  • 相关阅读:
    c#使用SoundPlayer播放wav格式音频
    c#NAudio 录音功能实现
    c#异步方法调用
    c# 读取文件目录下的信息
    angular笔记_1
    js获取form元素,不使用id
    事物回滚机制
    ckplayer跨域调用
    帝国移动pc站文章
    页面切换导航样式也随之改变
  • 原文地址:https://www.cnblogs.com/wgscd/p/13683713.html
Copyright © 2020-2023  润新知