Excel - How Can I Create Product Keys For VBA Applications So TH
Excel - How Can I Create Product Keys For VBA Applications So TH
7 My company wants to make it a product. This application should be installable only on one
system. Could someone please help me with this.
vba excel
10
Share Follow edited Dec 21, 2012 at 6:11 asked Dec 21, 2012 at 4:20
Siddharth Rout Developer
143k 17 199 246 269 5 7 19
Sorted by:
1 Answer
Highest score (default)
This is just a basic example on how to ensure that your product is installed on just one
system.
24
Logic:
1. Retrieve the Hardware ID (Ex: Hard Disk Number, CPU Number etc...)
2. You may also ask the user Name and email address
3. Encrypt the above info to generate an Unique Code (This is done within the App)
4. User sends you the Unique Code (Be it via email / Online Activation / Telephone)
Paste this code in a class module (Not my code. Copyright info mentioned in the code)
HD_MODEL_NUMBER
HD_SERIAL_NUMBER
HD_FIRMWARE_REVISION
End Enum
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
End Type
bFeaturesReg As Byte
bSectorCountReg As Byte
bSectorNumberReg As Byte
bCylLowReg As Byte
bCylHighReg As Byte
bDriveHeadReg As Byte
bCommandReg As Byte
bReserved As Byte
End Type
cBufferSize As Long
irDriveRegs As IDEREGS
bDriveNumber As Byte
bReserved(1 To 3) As Byte
dwReserved(1 To 4) As Long
End Type
bDriveError As Byte
bIDEStatus As Byte
bReserved(1 To 2) As Byte
dwReserved(1 To 2) As Long
End Type
cBufferSize As Long
DStatus As DRIVERSTATUS
End Type
Lib "kernel32" _
Join Stack Overflow to find the best answer to your technical question, help others
Sign up
answer theirs.
Private Declare Function DeviceIoControl _
Lib "kernel32" _
lpInBuffer As Any, _
lpOutBuffer As Any, _
lpBytesReturned As Long, _
(dest As Any, _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)
End Property
GetModelNumber = CmnGetHDData(HD_MODEL_NUMBER)
End Function
GetSerialNumber = CmnGetHDData(HD_SERIAL_NUMBER)
End Function
GetFirmwareRevision = CmnGetHDData(HD_FIRMWARE_REVISION)
End Function
End If
mvarCurrentDrive = vData
End Property
CurrentDrive = mvarCurrentDrive
End Property
Platform = mvarPlatform
End Property
OS.dwOSVersionInfoSize = Len(OS)
Call GetVersionEx(OS)
mvarPlatform = "Unk"
Select Case the best answer to your technical question, help others
Sign up
answer theirs. Case Is = VER_PLATFORM_WIN32S
mvarPlatform = "32S"
Case Is = VER_PLATFORM_WIN32_WINDOWS
If OS.dwMinorVersion = 0 Then
mvarPlatform = "W95"
Else
mvarPlatform = "W98"
End If
Case Is = VER_PLATFORM_WIN32_NT
mvarPlatform = "WNT"
End Select
End Sub
Dim br As Long
Dim ix As Long
Dim s As String
Case HD_MODEL_NUMBER
hddfr = 55
hddln = 40
Case HD_SERIAL_NUMBER
hddfr = 21
hddln = 20
Case HD_FIRMWARE_REVISION
hddfr = 47
hddln = 8
Case Else
End Select
Case "WNT"
0, OPEN_EXISTING, 0, 0)
hdh = CreateFile("\\.\Smartvsd", _
0, 0, 0, CREATE_NEW, 0, 0)
Case Else
End Select
If hdh = 0 Then
End If
With bin
.bDriveNumber = mvarCurrentDrive
.cBufferSize = 512
With .irDriveRegs
.bDriveHeadReg = &HB0
Else
.bDriveHeadReg = &HA0
.bSectorCountReg = 1
.bSectorNumberReg = 1
End With
End With
s = ""
For ix = hddfr To hddfr + hddln - 1 Step 2
s = s & Chr(bout.bBuffer(ix))
Next ix
CloseHandle hdh
CmnGetHDData = Trim(s)
End Function
Dim h As HDSN
With h
.CurrentDrive = 0
HDNo = .GetSerialNumber
End With
Set h = Nothing
Once you have this info, you can then merge it with the First Name, Last Name and the email
address to create a string. For example
Once you have the string, you can then encrypt it. Here is another basic example of encrypting
it. You can choose any type of encryption that you would like
For i = 1 To Len(strg)
Next
Once you receive this string, you will have to decode it and create an Activation Id based on
Join Stack Overflow to find the best answer to your technical question, help others
Signto
that. You App should be able to accept the Activation Id . You also have an option upstore
answer theirs.
this info in the registry or in a Dat File.
IMP: Though you can lock your VBA project but it is definitely not hack proof. You might want
to explore VSTO to create DLLs which does the above thing.
1 Thank you sooooooooooooo much for all the detailed steps. Highly appreciate you for taking time to
put together all the info. You saved my life. Thanks a ton.... – Developer Dec 21, 2012 at 6:30
@SiddharthRout Hi, so the idea behind is locking the VBA project? But as you mentioned, it can be
easily hack? – Larry Dec 21, 2012 at 6:50
2 @Larry: Locking the VBA project like I mentioned is not the ideal thing to do. One can take the VSTO
Join Stackapproach
Overflowto create the dlls. – Siddharth Rout Dec 21, 2012 at 6:52
to find the best answer to your technical question, help others
Sign up
answer theirs.
@SiddharthRout, does this work on x64 machine, like OS windows 8.1 x64 ? I plan to use this code in
MS Access VBA, we can have .accde which changes VBA to machine code. – Sham Yemul Jun 16, 2014
at 14:33
@SiddharthRout, I am getting sub or function not defined for GetWmiDeviceSingleValue. This does not
seem to be API, I searched Net and APIGuide. – Sham Yemul Jun 16, 2014 at 15:24
Highly active question. Earn 10 reputation (not counting the association bonus) in order to answer this
question. The reputation requirement helps protect this question from spam and non-answer activity.
Join Stack Overflow to find the best answer to your technical question, help others
Sign up
answer theirs.