[ActiveLock-Development] CVS: activelock/tutorials/vb/src Form1.frm,NONE,1.1 myapp.lic,NONE,1.1 Tuto
Brought to you by:
ialkan
From: Thanh H. T. <th...@us...> - 2003-11-26 06:06:02
|
Update of /cvsroot/activelock/activelock/tutorials/vb/src In directory sc8-pr-cvs1:/tmp/cvs-serv25730 Added Files: Form1.frm myapp.lic TutorialApp.vbp Log Message: Source code for the tutorial --- NEW FILE: Form1.frm --- VERSION 5.00 Begin VB.Form Form1 BorderStyle = 1 'Fixed Single Caption = "myApp Form" ClientHeight = 3735 ClientLeft = 45 ClientTop = 330 ClientWidth = 8730 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 3735 ScaleWidth = 8730 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmdReg Caption = "&Register" Height = 375 Left = 7560 TabIndex = 6 Top = 720 Width = 975 End Begin VB.TextBox txtLibKey BeginProperty Font Name = "Courier New" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 2895 Left = 1320 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 5 Top = 720 Width = 6135 End Begin VB.TextBox txtUser Height = 315 Left = 1320 TabIndex = 1 Top = 0 Width = 5055 End Begin VB.TextBox txtInstCode BackColor = &H8000000F& Height = 315 Left = 1320 Locked = -1 'True MultiLine = -1 'True TabIndex = 3 Top = 360 Width = 7215 End Begin VB.Label Label3 Caption = "Liberation Key:" Height = 495 Left = 0 TabIndex = 4 Top = 720 Width = 1215 End Begin VB.Label Label2 Caption = "Registered User:" Height = 255 Left = 0 TabIndex = 0 Top = 0 Width = 1335 End Begin VB.Label Label1 Caption = "Installation Code:" Height = 255 Left = 0 TabIndex = 2 Top = 360 Width = 1455 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private ActiveLock As ActiveLock2.IActiveLock Private WithEvents ActiveLockEventSink As ActiveLockEventNotifier Attribute ActiveLockEventSink.VB_VarHelpID = -1 Private Sub cmdReg_Click() ' Be prepared to handle registration error (e.g. invalid license) On Error GoTo ErrHandler ActiveLock.Register txtLibKey ' No error. This means success! MsgBox "License was successfully registered!" Exit Sub ErrHandler: MsgBox Err.Description End Sub Private Sub Form_Load() On Error GoTo ErrHandler ' Obtain an instance of ActiveLock object Set ActiveLock = ActiveLock2.NewInstance() ' Specify where the license file is ActiveLock.KeyStoreType = alsFile ActiveLock.KeyStorePath = App.Path & "\myapp.lic" ' Obtain the EventNotifier so that we can receive notifications from AL. Set ActiveLockEventSink = ActiveLock.EventNotifier ' Specify the name of the product that will be locked through AL. ActiveLock.SoftwareName = "MyApp" ' Specify our product code. ' This code will be used later by ActiveLock to validate license keys. ActiveLock.SoftwareCode = "AAAAB3NzaC1yc2EAAAABJQAAAIB9JNUb5AAI7xnlCRB2muU0PO/Q5jY/hVz1yF6Uvjyjm56QX6KxDYMGsOraAZZTGKX+i29P3dHT87ORyX8Cesb0/aicgA5ZBAyUEVHgYH20SqjtIOSZYTGyGfzrpecWXDKz0zWcNala+TA8jGasV2iKb5zsSdsG3Ces9kNPomLHMw==" ' Specify product version ActiveLock.SoftwareVersion = "1.0" ' Specify Lock Type as Lock-to-HardDrive. The System drive (where Windows is installed) will be used as part of the lock key. ActiveLock.LockType = lockHD ' Display the Installation Code txtInstCode = ActiveLock.InstallationCode ' Attempt to acquire a valid license token ActiveLock.Acquire ' Acquire will raise an error if no valid license exists. ' Do some queries on the registration status, such as who it's registered to, etc... txtUser = ActiveLock.RegisteredUser Exit Sub ' Exit Form_Load() ErrHandler: MsgBox "ActiveLock Error: " & Err.Description End Sub ' Re-compute Installation Code when "Registered User" changes Private Sub txtUser_Change() txtInstCode = ActiveLock.InstallationCode(txtUser) End Sub '' ' Simple encryption of a string: simply mutiply every character's ASCII code by 11. ' Private Function Enc(strData As String) As String Dim i&, n& Dim sResult$ n = Len(strData) Dim l As Long For i = 1 To n l = Asc(Mid$(strData, i, 1)) * 11 If sResult = "" Then sResult = Hex(l) Else sResult = sResult & "." & Hex(l) End If Next i Enc = sResult End Function '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ActiveLockEventSink Implementations '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub ActiveLockEventSink_ValidateValue(ByRef Value As String) Value = Enc(Value) End Sub --- NEW FILE: myapp.lic --- [MyApp] ProductKey=AAAAB3NzaC1yc2EAAAABJQAAAIB9JNUb5AAI7xnlCRB2muU0PO/Q5jY/hVz1yF6Uvjyjm56QX6KxDYMGsOraAZZTGKX+i29P3dHT87ORyX8Cesb0/aicgA5ZBAyUEVHgYH20SqjtIOSZYTGyGfzrpecWXDKz0zWcNala+TA8jGasV2iKb5zsSdsG3Ces9kNPomLHMw== ProductVersion=1.0 LicenseType=3 LicenseClass=Single Licensee=John Q Public LicenseKey=AAAAB3NzaC1yc2EAAACAQpQF1xrjJcxyKJO8oO7fb2XgDMFwpHmYMSHKje/4tsj/WiOdqgrEm6qs0Vx0tnM8xco2VyPZRuuLYWRLShy1wkiAy01+Hh7l4QrCf6CP3qOcP+mTY9zymBnMOvlVGeBPCj24MC0MzieDEF2Byf7XprTiBZLG8eXS8SuIOtEmwjQ RegisteredDate=2003/11/02 LastUsed=2003/11/10 23:52:17 Hash1=8a5fc6a619c931b7509adc6da3cef35f Expiration=2003/12/02 MaxCount=1 --- NEW FILE: TutorialApp.vbp --- Type=Exe Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\System32\stdole2.tlb#OLE Automation Reference=*\G{C3B56087-6690-42ED-8914-633AA166AB41}#1.0#0#..\..\..\bin\activelock2.dll#ActiveLock Object Library 2.0 Form=Form1.frm Startup="Form1" Command32="" Name="TutorialApp" HelpContextID="0" CompatibleMode="0" MajorVer=1 MinorVer=0 RevisionVer=0 AutoIncrementVer=0 ServerSupportFiles=0 VersionCompanyName="Karora Technologies Inc." CompilationType=0 OptimizationType=0 FavorPentiumPro(tm)=0 CodeViewDebugInfo=0 NoAliasing=0 BoundsCheck=0 OverflowCheck=0 FlPointCheck=0 FDIVCheck=0 UnroundedFP=0 StartMode=0 Unattended=0 Retained=0 ThreadPerObject=0 MaxNumberOfThreads=1 [MS Transaction Server] AutoRefresh=1 |