0

可能重复:
如何将我的产品作为试用版 30 天?
实施 30 天的时间试用

我正在编写一个试用应用程序,它有 30 天的试用期,

为了为用户保留 30 天,我需要检查系统时间的变化,

例如,如果用户在系统日期和时间中添加两天,它不会损害试用期,并且通过从 DateTime.now 中减去时间变化,它将保持 30 天

我通过阅读事件日志找到了一种方法,但我需要管理权限才能这样做,这并不总是可用的。

有没有办法在不需要管理权限的情况下获取此类信息?

4

2 回答 2

1

Instead of looking for the change in the system time, you could use a database that logs the date of the first day, and calculate the 30 time span after the first day.

So when the user opens the application for the first time, you will have to query your database to add the date of today(first time opening's date) and 30 days after today(first time opening's date)

To acquire the date of today and 30 days after, use the DateTime.Now function.

        string Today = DateTime.Now.Day + " - " + DateTime.Now.Month + " - " + DateTime.Now.Year;
        string End = DateTime.Now.AddDays(30).Day + " - " + DateTime.Now.AddDays(30).Month + " - " + DateTime.Now.AddDays(30).Year;

The downside to the above method is that if the user starts his application at say, year 2070. Then his application will not expire until year 2070.

So it is best if you get the date from an online source http://www.thetimenow.com/ instead of getting the date from the user's computer.

于 2012-11-22T08:07:46.677 回答
-1

您可以通过保存剩余天数、安装datetime和最后检查来尝试datetime。确保两者都在安装时设置。

当用户启动程序时

if (lastCheck > DateTime.Now)
    {
         lastCheck = DateTime.Now;
    }
else
    {
         remainingDays = (DateTime.Now - lastCheck).TottalDays;
    }

如果没有进一步的修改,这将阻止用户修改日期,因为这会减少他设置日期时的剩余时间。你可以用更多的代码来避免这种情况。我认为它相当简单而有效。

编辑:我可能误解了这个问题。

如果没有代码过度杀伤,我看不出有任何方法可以做到这一点。最重要的是保护您的应用程序不被破解/利用。如果用户想玩日期,那是他们的损失。

如果由于应用程序的性质这是可以预料的,那么它应该在应用程序完成之前处理。

于 2012-11-22T08:12:06.963 回答