如何在Windows应用程序中使用过期日期。 [英] How do I use Expire date in windows Application.
问题描述
如何在Windows应用程序中使用过期日期代码,并且应用程序必须在过期日期后关闭,即使用户将系统日期更改为上一个日期,应用程序也不起作用。请有人帮我解决这个问题。
我的Windows应用程序使用了这个vb.net代码,但如果我更改了系统日期,那么应用程序就会运行。 br $> b $ b
[代码]
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System。处理MyBase.Load)
Dim dateFile As String =\ Data.txt
Dim filePath As String = My.Computer .FileSystem.SpecialDirectories.Programs
Dim fullPathAndFilename As String = filePath&dateFile
Dim dateFromFile As Date
Dim ts As TimeSpan
如果System.IO.File.Exists(fullPathAndFilename)= True那么
使用sr作为新的System.IO.StreamReader(fullPathAndFilename)
Date.TryParse(sr.ReadLine,dateFromFile)
ts = Now.Subtra ct(dateFromFile)
如果ts.TotalDays> 1然后
昏暗的结果As DialogResult = MessageBox.Show(软件试用期满了,抱歉。)
如果result = Windows.Forms.DialogResult.OK或者result = Windows .Forms.DialogResult.Cancel然后
sr.Close()
结束
结束如果
Else
结束如果
sr.Close()
结束使用
ElseIf System.IO.File.Exists(fullPathAndFilename)= False然后
使用sw作为新的System.IO.StreamWriter(fullPathAndFilename)
sw.WriteLine (Now.ToLongDateString&&Now.ToLongTimeString)
sw.Close()
结束使用
结束如果
结束子
[/ CODE]
谢谢和问候
BASVA。
除了使用外部日期和时间服务(例如您自己的网站)验证应用程序是否正确外,没有真正的方法可以完全避免此问题仍然在它的有效期内。
但你可以通过记录上次在配置文件中使用的日期和时间并在开始时检查它来提供帮助 - 如果你早于最后使用价值然后出现问题!但要小心:首先,季节性的时钟变化不会影响你,并且用户可以合理地纠正他的系统时钟,而不会被告知他是一个小偷! (我的系统例如每隔一段时间校正一次互联网时间服务,所以它总是非常正确的。)
没有什么比不能使合法客户烦恼使用他们支付的软件,因为你的检查得到误报! :笑:
How do I Use an Expire date code in Windows Applications, and The application must close after the expire date and the application does not work even though when the user changes system date to previous date. Please anyone help me out of this problem.
I used this vb.net code for my Windows Application, but if I change the system date then application will run.
[CODE]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dateFile As String = "\Data.txt"
Dim filePath As String = My.Computer.FileSystem.SpecialDirectories.Programs
Dim fullPathAndFilename As String = filePath & dateFile
Dim dateFromFile As Date
Dim ts As TimeSpan
If System.IO.File.Exists(fullPathAndFilename) = True Then
Using sr As New System.IO.StreamReader(fullPathAndFilename)
Date.TryParse(sr.ReadLine, dateFromFile)
ts = Now.Subtract(dateFromFile)
If ts.TotalDays > 1 Then
Dim result As DialogResult = MessageBox.Show("Software trial expired, sorry.")
If result = Windows.Forms.DialogResult.OK Or result = Windows.Forms.DialogResult.Cancel Then
sr.Close()
End
End If
Else
End If
sr.Close()
End Using
ElseIf System.IO.File.Exists(fullPathAndFilename) = False Then
Using sw As New System.IO.StreamWriter(fullPathAndFilename)
sw.WriteLine(Now.ToLongDateString & " " & Now.ToLongTimeString)
sw.Close()
End Using
End If
End Sub
[/CODE]
Thanks and Regards
BASVA.
There is no real way to be completely secure from this problem, except to use an external date and time service (such as your own website) to verify that an application is still within it's expiration period.
But you can help by recording the date and time of the last use in a config file somewhere and checking that when you start - if you are earlier than the "last use" value then something is amiss! But be careful: firstly that seasonal clock changes don't affect you, and that the user can legitimately correct his system clock without being told he is a thief! (My system for example corrects itself to an internet time service at intervals so it is always pretty much correct).
Nothing will annoy legitimate customers more than not being able to use the software they have paid for because your checking gets a false positive! :laugh:
这篇关于如何在Windows应用程序中使用过期日期。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!