博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
创建WP8试用应用
阅读量:7089 次
发布时间:2019-06-28

本文共 1769 字,大约阅读时间需要 5 分钟。

参考资料:

 

对资料总结下:

如何检查应用中的试用许可证:

在App.xaml.cs中添加下面两行

using Microsoft.Phone.Marketplace;

private static LicenseInformation _licenseInfo = new LicenseInformation();

使用_licenseInfo.IsTrial()方法,即读取LicenseInformation对象上的IsTrial属性,返回True时为试用版,否则为付费版

但是实际上在调试时,应用的真实许可信息只有在发布到商店后才能使用,所以再在App.xaml.cs里使用以下两段代码。使用后,在调试时将执行#if Debug与#else之间的代码,进行手动设置是否为试用版;在释放模式下时,将执行#else与#endif之间的代码,即读取LicenseInformation对象上的IsTrial属性来设置是否试用版。

private static bool _isTrial = true;        public bool IsTrial        {            get            {                return _isTrial;            }        }
///         /// Check the current license information for this application        ///         private void CheckLicense()        {            // When debugging, we want to simulate a trial mode experience. The following conditional allows us to set the _isTrial             // property to simulate trial mode being on or off. #if DEBUG            string message = "This sample demonstrates the implementation of a trial mode in an application." +                               "Press 'OK' to simulate trial mode. Press 'Cancel' to run the application in normal mode.";            if (MessageBox.Show(message, "Debug Trial",                 MessageBoxButton.OKCancel) == MessageBoxResult.OK)            {                _isTrial = true;            }            else            {                _isTrial = false;            }#else            _isTrial = _licenseInfo.IsTrial();#endif        }

 

在应用开始或恢复时都需要检查应用的许可证:

即在App.xaml.cs中的Application_Launching和Application_Activated事件中添加试用版的判断方法CheckLicense()

 

使用当前应用的许可证信息:

由于在App.xaml.cs里设置了IsTrial属性来读取许可证属性,因此我们可以通过使用(Application.Current as App).IsTrial属性来直接获取应用的许可证信息,避免重复使用IsTrial()方法,该方法一次典型调用耗时60毫秒或更多。

转载于:https://www.cnblogs.com/Scohura/p/4143266.html

你可能感兴趣的文章
JS BUG 传递数字过大,数据值会变化
查看>>
橡皮筋进度条ElasticProgressBar
查看>>
spring boot引入json,jsonobject,需要指定jdk15
查看>>
企业架构 - 涉众管理(Stakeholder Management)
查看>>
Ubuntu11.10 解决rar文件解压错误
查看>>
sqlplus: error while loading shared libraries: /u01/app/lib/libclntsh.so.11.1
查看>>
ORACLE等待事件:enq: TX - row lock contention
查看>>
使用Fiddler2录制HTTP操作脚本
查看>>
响应activex事件
查看>>
Winform 进程之间通讯的几种方法
查看>>
c++中冒号(:)和双冒号(::)的用法
查看>>
dubbo工作原理
查看>>
驱动开发利器Microsoft Windows Driver Kit 7.1.0下载
查看>>
maven_项目的依赖、聚合、继承
查看>>
一个C++类的注释:
查看>>
Winsock IO模型之select模型
查看>>
开发规范
查看>>
PHP json_decode object时报错Cannot use object of type stdClass as array
查看>>
hibernate一对一外键双向关联
查看>>
SharePoint 2013 同步FBA认证用户
查看>>