我想在软件中用户单位表中设计了使用期限,并且加了密,用户单位表结构如下
此主题相关图片如下:ss.jpg
接下来在项目事件AfterOpenProject中写上 代码
Dim dt1 As Date
If TryConnectHost("www.163.com") Then
dt1=functions.Execute("getdate")
Else
dt1 = Date.Today
End If
try
If Cdate(DecryptText(zcqx,"嘻嘻网络","www.wjhans.com"))>dt1 Then '软件过期
Else
Forms("到期提示").show()
End If
catch
Forms("到期提示格式错误").show()
End try
设置为显示
内部函数getdate代码为
Dim TimeServers As String(,) = New String(2, 1) {}
TimeServers(0, 0) = "time-b.timefreq.bldrdoc.gov"
TimeServers(0, 1) = "132.163.4.102"
TimeServers(1, 0) = "time-c.timefreq.bldrdoc.gov"
TimeServers(1, 1) = "132.163.4.103"
TimeServers(2, 0) = "utcnist.colorado.edu"
TimeServers(2, 1) = "128.138.140.44"
Dim portNum As Integer = 13
Dim hostName As String
Dim bytes As Byte() = New Byte(1023) {}
Dim bytesRead As Integer = 0
Dim client As New System.Net.Sockets.TcpClient()
For i As Integer = 0 To 2
hostName = TimeServers(i, 1)
Try
client.Connect(hostName, portNum)
Dim ns As System.Net.Sockets.NetworkStream = client.GetStream()
bytesRead = ns.Read(bytes, 0, bytes.Length)
client.Close()
Exit For
Catch generatedExceptionName As System.Exception
End Try
Next
Dim sp As Char() = New Char(0) {}
sp(0) = " "c
Dim dt As System.DateTime = New DateTime()
Dim str1 As String
str1 = System.Text.Encoding.ASCII.GetString(bytes, 0, bytesRead)
Dim s As String()
s = str1.Split(sp)
dt = System.DateTime.Parse(s(1) & " " & s(2))
'得到标准时间
dt = dt.AddHours(8)
'得到北京时间
Dim getdate As Date
getdate=dt.Date
Return getdate
经测算:如果使用期限过期了 ,到期提示窗口有时会出现,有时不会出现,不知道什么原因,恳请老师指点,或者有没有更好的办法
解决使用期限的问题