Sub Activity_Create(FirstTime As Boolean)
If CheckLicense = False Then Activity.Finish
End Sub
Sub CheckLicense As Boolean
Dim InputBox As InputDialog
Dim PhID As String
Dim ph As PhoneId
PhID = ph.GetDeviceId
Dim KeySaved As String
Dim Key As StringBuilder
Key.Initialize
For i = 0 To PhID.Length -1
Key.Append(KeyGen(PhID.SubString2(i,i+1)))
Next
If File.Exists(File.DirInternal, "License.dat") Then
Rf.Initialize(File.DirInternal,"License.dat",True)
KeySaved = Rf.ReadObject(Rf.CurrentPosition)
Rf.Close
If KeySaved = Key.ToString Then Return True
If KeySaved <> Key.ToString Then
InputBox.InputType = InputBox.INPUT_TYPE_TEXT
InputBox.PasswordMode = False
InputBox.Show("Insert License Key","License Key","OK","Cancel","",Null)
If InputBox.Response = -3 Then Return False
If InputBox.Response = -1 Then
If Key.ToString = InputBox.Input Then
KeySaved = InputBox.Input
Rf.Initialize(File.DirInternal,"License.dat",False)
Rf.WriteObject(KeySaved,False,Rf.CurrentPosition)
Rf.Close
Return True
End If
End If
End If
Else
InputBox.InputType = InputBox.INPUT_TYPE_TEXT
InputBox.PasswordMode = False
InputBox.Show("Insert License Key","License Key","OK","Cancel","",Null)
If InputBox.Response = -3 Then Return False
If InputBox.Response = -1 Then
If Key.ToString = InputBox.Input Then
KeySaved = InputBox.Input
Rf.Initialize(File.DirInternal,"License.dat",False)
Rf.WriteObject(KeySaved,False,Rf.CurrentPosition)
Rf.Close
Return True
End If
End If
End If
End Sub
Sub KeyGen(PartKey As String) As String
PartKey = PartKey.ToUpperCase
Select Case PartKey
Case "0"
Return "AL"
Case "1"
Return "BH"
Case "2"
Return "CF"
Case "3"
Return "DE"
Case "4"
Return "ED"
Case "5"
Return "FC"
Case "6"
Return "GB"
Case "7"
Return "HA"
Case "8"
Return "IM"
Case "9"
Return "LN"
Case "A"
Return "0"
Case "B"
Return "1"
Case "C"
Return "2"
Case "D"
Return "3"
Case "E"
Return "4"
Case "F"
Return "5"
Case "G"
Return "6"
Case "H"
Return "7"
Case "I"
Return "8"
Case "J"
Return "9"
Case "Y"
Return "10"
Case "K"
Return "11"
Case "L"
Return "12"
Case "M"
Return "13"
Case "N"
Return "14"
Case "O"
Return "15"
Case "P"
Return "16"
Case "Q"
Return "17"
Case "R"
Return "18"
Case "S"
Return "19"
Case "T"
Return "20"
Case "U"
Return "21"
Case "V"
Return "22"
Case "Z"
Return "23"
End Select
End Sub