Karena adanya koreksi itu saya jadi punya ide untuk menulis artikel ini :D
Oke kita langsung saja, file library yang akan kita gunakan disini adalah IKGCG.DLL (untuk generate serial number) dan ISID.DLL (untuk melakukan validasi serial number)
Langkah awal sebelum kita masuk ke bagian kode program adalah membuat file Inno Key yang berfungsi sebagai public key yang akan kita distribusikan bersama aplikasi.
Membuat Form Keygen
Buat project baru kemudian desain tampilan seperti gambar berikut :
download file IKGCG.rar, ekstrak dan copykan ke folder project. Berikut adalah source code lengkapnya :
1234567891011121314151617181920
Option Explicit
Private Declare Function GenerateSerialNumber Lib "IKGCG.DLL" (ByVal innoKeyFile As String, ByVal User As String, ByVal Orgn As String, ByVal ProdCode As String, ByVal HDD As String, ByVal MAC As String, ByVal privateKey As String, ByVal UnlockCode As String) As Boolean
Private Function getSerialNumber(ByVal registeredName As String, ByVal organisation As String) As String
Dim innoKeyFile As String
Dim privateKey As String
Dim serialNumber As String * 12
Dim ret As Boolean
innoKeyFile = App.Path & "\key.iky"
privateKey = "3D07966E-9AB4-4EBE-BF41-91C2D6611AC0" 'nilai ini didapat pada saat pembuatan file inno key
ret = GenerateSerialNumber(innoKeyFile, registeredName, organisation, "", "", "", privateKey, serialNumber)
getSerialNumber = serialNumber
End Function
Private Sub cmdGenerate_Click()
txtSerialNumber.Text = getSerialNumber(txtRegisteredName.Text, txtOrganisation.Text)
End Sub
Hal penting yang perlu diperhatikan pada source code diatas adalah nilai variabel privateKey, nilai ini harus sama dengan nilai PRIVATE KEY pada saat membuat file Inno Key
Membuat Form Aktivasi
Setelah kita selesai mendesain tampilan seperti gambar diatas download file ISID.rar, ekstrak dan copykan ke folder project. Berikut kode lengkapnya :
Option Explicit
Private Declare Function ValidateSerialNumber Lib "ISID.DLL" (ByVal innoKeyFile As String, ByVal User As String, ByVal Orgn As String, ByVal ProdCode As String, ByVal HDD As String, ByVal MAC As String, ByVal privateKey As String, ByVal Serial As String) As Boolean
Public Function isValidSerialNumber(ByVal registeredName As String, ByVal organisation As String, ByVal serialNumber As String) As Boolean
Dim innoKeyFile As String
Dim privateKey As String
Dim ret As Boolean
innoKeyFile = App.Path & "\key.iky"
privateKey = "3D07966E-9AB4-4EBE-BF41-91C2D6611AC0" 'nilai ini didapat pada saat pembuatan file inno key
isValidSerialNumber = ValidateSerialNumber(innoKeyFile, registeredName, organisation, "", "", "", privateKey, serialNumber)
End Function
Public Sub Main()
Dim registeredName As String
Dim organisation As String
Dim serialNumber As String
registeredName = GetSetting("MyApp", "Aktivasi", "RegisteredName", "")
organisation = GetSetting("MyApp", "Aktivasi", "Organisation", "")
serialNumber = GetSetting("MyApp", "Aktivasi", "SerialNumber", "")
If isValidSerialNumber(registeredName, organisation, serialNumber) Then
'TODO : tampilkan form utama
Else
frmAktivasi.Show
End If
End Sub
Selanjutnya tinggal pangil di form aktivasi seperti berikut :
1234567891011121314151617181920
Option Explicit
Private Sub cmdOk_Click()
If isValidSerialNumber(txtRegisteredName.Text, txtOrganisation.Text, txtSerialNumber.Text) Then
Call SaveSetting("MyApp", "Aktivasi", "RegisteredName", txtRegisteredName.Text)
Call SaveSetting("MyApp", "Aktivasi", "Organisation", txtOrganisation.Text)
Call SaveSetting("MyApp", "Aktivasi", "SerialNumber", txtSerialNumber.Text)
MsgBox "Aktivasi berhasil", vbInformation, "Informasi"
'TODO : tampilkan form utama
Else
MsgBox "Aktivasi gagal", vbExclamation, "Peringatan"
End If
End Sub
Private Sub Command1_Click()
Unload Me
End Sub