简体   繁体   English

安装后仅两个月如何运行应用程序

[英]How to run application only for 2 months after installation

I am developing WPF application , i want it to run only for 2 months after the installation . 我正在开发WPF application ,我希望它2 months after the installation仅运行2 months after the installation

How to get the installation date once the application installed on the computer.? 一旦在计算机上安装了应用程序,如何获取安装日期? Is it possible in WPF app.? 在WPF应用中可以吗?

Easiest is to check the last write date of the application itself. 最简单的方法是检查应用程序本身的最后写入日期。 When installing the application the last write date is set to the current date. 安装应用程序时,最后写入日期设置为当前日期。 In your application you can do something like that (just typed in the browser, might have small typos): 在您的应用程序中,您可以执行以下操作(只需在浏览器中键入,可能会有小的错别字):

if(File.GetLastWriteTime(Application.ExecutablePath) < DateTime.Now.AddMonths(-2))
{
    // Show message and then close the application
}

Be aware that this is not really a safe check. 请注意,这并不是真正的安全检查。 A user can easily change the LastWriteDate of the application and then use it again. 用户可以轻松地更改应用程序的LastWriteDate,然后再次使用它。

Update: 更新:

Changed the file name from "MyApp.exe" to Application.ExecutablePath 将文件名从“ MyApp.exe”更改为Application.ExecutablePath

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM