[VB6][VBA][C#][JAVA] 製作簡易 時間/次數 測試版 試用版

  • 17584
  • 0
  • VB6
  • 2008-11-30

摘要:[VB6][VBA][C#][JAVA] 製作簡易 時間/次數 測試版 試用版

測試版功能可以運用在專案裡,提供給使用,以下是使用VB6進行範例說明,VB2005及VBA同樣可以套用

功能說明:程式試用到本月的30號如果超過本月30號則無法執行。
函數說明:本程式主要是利用GetSetting從機碼取得已運行的天數,再利用SaveSetting儲存機碼
http://msdn.microsoft.com/zh-tw/library/kb0c3wb9(VS.80).aspx

試用到月底:

Private Sub Form_Load()
    Dim RemainDay As Long
    RemainDay = GetSetting("MyApp", "set", "days", Day(Date))
    If RemainDay >= 30 Then
        MsgBox "試用期已過"
        End
        Exit Sub
    End If
    MsgBox "還剩下" & 30 - RemainDay & "試用天數"
    If Day(Date) - RemainDay > 0 Then
        RemainDay = RemainDay + 1
        SaveSetting "MyApp", "set", "days", RemainDay
    End If
End Sub

試用30次:

Private Sub Form_Load()
    Dim RemainDay As Long
    RemainDay = GetSetting("MyApp", "set", "times", 0)
    If RemainDay = 30 Then
        MsgBox "試用次數已滿,請花錢買正版"
        Unload Me
        End
    End If
    MsgBox "現在剩下:" & 30 - RemainDay & "試用次數,好好珍惜!"
    RemainDay = RemainDay + 1
    SaveSetting "MyApp", "set", "times", RemainDay
End Sub

試用30天:

Private Sub Form_Load()
    Dim RemainDay As Long
    RemainDay = GetSetting("MyApp", "set", "day", 0)
    If RemainDay = 30 Then
        MsgBox "試用期已過,請花錢買正版"
        Unload Me
    End If
    MsgBox "現在剩下:" & 30 - RemainDay & "試用天數,好好珍惜!"
    If Day(Now) - RemainDay > 0 Then RemainDay = RemainDay + 1
    SaveSetting "MyApp", "set", "tdays", RemainDay
End Sub

 .Net Framework:My.Computer.Registry
同樣的邏輯C#也是可以利用

JAVA API:Package java.rmi.registry
同樣的也適用在JAVA
http://java.sun.com/j2se/1.4.2/docs/api/java/rmi/registry/package-summary.html
http://www.kuqin.com/J2SE6-API/java/rmi/registry/package-summary.html

 

 


若有謬誤,煩請告知,新手發帖請多包涵


Microsoft MVP Award 2010~2017 C# 第四季
Microsoft MVP Award 2018~2022 .NET

Image result for microsoft+mvp+logo