Martin I am new to VB and I think i might be slow in understanding the VB concepts. I don't want to make assumptions, 1- When compiling my program should I include the Key generator program too? 2 - You mentioned that one should change the alogarythm in the project, this should be changed too what before compiling it?
Well since I have email I can't test the program with %100 confidence, but when an error occurrs in the RequestKey function because for example you don't have an email program, it displays frmRegError which contains the registration info. Have you run the program before? If so you may already be registered and so you won't get to that function. Check the registry and delete your former information and try it again.
No, I have not yet run thr prog. I want to understand it b4 running it so that i don't make errors. Like i mentioned i need to know what and what exactly i should chage b4 running it
Martin I am new to VB and I think i might be slow in understanding the VB concepts. I don't want to make assumptions, 1- When compiling my program should I include the Key generator program too? 2 - You mentioned that one should change the alogarythm in the project, this should be changed too what before compiling it?
Hope you understand my sitauation.
Thanks
Sorry, I missed this post of yours.
1) No. That is just for you. After the user gets his information to you, you use that program to generate his key.
2) I believe the formula in the two programs is now
That is just an arbitrary calculation and you could change it to anything you want such as any of the following. You don't actually have to change it at all, but if you don't then some knowledgeable user might stumble across the existing formula and be able to register without contacting you.
Hello Martin,
I stumbled across your site looking for just this application to use for MS Access applications I have written. I take note that your code is written for VB and not VBA and will be looking at suitable adjustments.
I haven't at this time opened your project, but accept that it functions as you have described. I have read all of this thread and I am impressed with the way you have zeroed in on issues raised.
The applications I have written are used on a LAN comprising some 50-100 workstations with the application residing on a central server. My question is: Will the program need to be registered only on the computer it is loaded on or on each computer it will run on?
First, I assume you'll have to make modifications to the program in order to run it in a VBA app. As to your question, as written the program assumes that it is installed on an individual's PC and so each user needs to register. The code is of course yours to do what you want with, so you can modify it as you see fit.
Hi,
this is a nice program. I have set up similar code a while ago with a program I made for a company for private use. It was a small company so it was easy to keep track of. What I did was I generated a serial using the following information:
HDD serial number
MAC Address
Processor ID
Windows Product ID
I then concatenated the strings generated from the above items into one long string, and encrypted the string using a specific encryption (which, if you use this method is up to you). I used the encrypted string as a unique ID to generate the serial number.
This may be thought of as excessive (and possibly redundant) but it helped protect unauthorized people from using the application. On top of that, once a serial number was generated for a specific computer it was added to a database controlled by myself of active serial numbers. Every time the user logged in to the program, it verified the computer's information with the serial number, then it contacts my "active serial" database to check if it's serial number is ok.
If the serial number did not check out for whatever reason (i.e. changed hardware in computer) they are prompted to request a new serial number from me.
Again, some of you may think this is extremely excessive and redundant... but I do not.
One reason I did this was because I originally started out using ONLY the hdd serial number as a unique identifier like the project posted in this thread, but I quickly realized 2 things:
1. The code I found for the HDD serial number did NOT return the HDD serial number, but rather the partition's volume number. This is a totally different thing. For example, if you have 2 partitions on a hdd, the code would return the volume id for a specified partition (i.e. C: drive)
2. I found code that actually retrieved the HDD's serial number (the serial number that is put in by the manufacturer of the HDD). BUT for some reason, some computers returned the proper serial number from the manufacturer and some did not return anything at all. This posed a slight problem.
What happens when you try to download it? I just downloaded it a few minutes ago.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Yes Martinlis I change it to double in both
how about this one?
Code:
Public Function GetSerialNumber() As Long
Dim strVolumeBuffer As String
Dim strSysName As String
Dim lngSerialNumber As Long
Dim lngSysFlags As Long
Dim lngComponentLen As Long
Dim lngResult As Long
strVolumeBuffer$ = VBA.String$(256, 0)
strSysName$ = VBA.String$(256, 0)
lngResult = GetVolumeInformation("C:\", strVolumeBuffer$, 255, lngSerialNumber, _
lngComponentLen, lngSysFlags, strSysName$, 255)
GetSerialNumber = lngSerialNumber
End Function
and this one
Code:
Public Function CalcRegKey(lngSerialNum As Long) As String
Dim strLicenseKey As String
Const ZEROS = "000000000"
lngSerialNum = Abs(lngSerialNum)
' This calculation must be the same as the one used in GenKey
strLicenseKey = CStr(Int(3456 * Sqr(Abs(lngSerialNum) / 5)))
strLicenseKey = VBA.Left$(strLicenseKey, 9)
If Len(strLicenseKey) < 9 Then
strLicenseKey = VBA.Left$(ZEROS, 9 - Len(strLicenseKey)) & strLicenseKey
End If
CalcRegKey = strLicenseKey
End Function
Public Sub Main()
Dim strLicenseKey As String
Dim lngSerialNum As Double
Const ZEROS = "000000000"
lngSerialNum = InputBox("Enter user's hard drive serial number")
' This calculation must be the same as the one used in your application
strLicenseKey = CStr(Int(3456 * Sqr(lngSerialNum / 5)))
strLicenseKey = Left$(strLicenseKey, 9)
If Len(strLicenseKey) < 9 Then
strLicenseKey = Left$(ZEROS, 9 - Len(strLicenseKey)) & strLicenseKey
End If
strLicenseKey = Format(strLicenseKey, "@@@-@@@-@@@")
frmGenKey.txtKey = strLicenseKey
frmGenKey.Show vbModal
End Sub
and this from protect
Code:
Public Function CalcRegKey(lngSerialNum As Long) As String
Dim strLicenseKey As String
Const ZEROS = "000000000"
lngSerialNum = Abs(lngSerialNum)
' This calculation must be the same as the one used in GenKey
strLicenseKey = CStr(Int(3456 * Sqr(Abs(lngSerialNum) / 5)))
strLicenseKey = VBA.Left$(strLicenseKey, 9)
If Len(strLicenseKey) < 9 Then
strLicenseKey = VBA.Left$(ZEROS, 9 - Len(strLicenseKey)) & strLicenseKey
End If
CalcRegKey = strLicenseKey
End Function
how about this from protect
Code:
Public Function GetSerialNumber() As Long
Dim strVolumeBuffer As String
Dim strSysName As String
Dim lngSerialNumber As Long
Dim lngSysFlags As Long
Dim lngComponentLen As Long
Dim lngResult As Long
strVolumeBuffer$ = VBA.String$(256, 0)
strSysName$ = VBA.String$(256, 0)
lngResult = GetVolumeInformation("C:\", strVolumeBuffer$, 255, lngSerialNumber, _
lngComponentLen, lngSysFlags, strSysName$, 255)
GetSerialNumber = lngSerialNumber
End Function
Public Function GetSerialNumber() As double
Dim strVolumeBuffer As String
Dim strSysName As String
Dim lngSerialNumber As double
Dim lngSysFlags As Long
Dim lngComponentLen As Long
Dim lngResult As Long
strVolumeBuffer$ = VBA.String$(256, 0)
strSysName$ = VBA.String$(256, 0)
lngResult = GetVolumeInformation("C:\", strVolumeBuffer$, 255, lngSerialNumber, _
lngComponentLen, lngSysFlags, strSysName$, 255)
GetSerialNumber = lngSerialNumber
End Function
come with "compile error byref argument type mismatch"
code marked italic.
Attached is a project (actually two projects) that show one way of having the user register his copy of your program. This is the way it works:
The main application displays a registration screen with two options: "Register" and "Request Registration Key".
If the user selects "Register" a new screen is shown that asks the user for his name and tells him that if he continues it will generate an e-mail message to you (via MAPI) and that you will send him the registration key by return e-mail. If he continues, the program gets his hard drive serial number and includes it in the e-mail to you.
Once you receive the registration request email, you use the second project (GenKey) to generate a registration key by way of a simple algorithm that you can change based on the hard drive serial number. Just remember that the algorithm is in both projects and it must be exactly the same in both.
You then send the registration key back to the user and have them enter it in the second part of the registration screen which writes the key to the registry.
When they start the main program again it uses the same algorithm to see if the registration key in the Registry matches the HD serial number. If it matches the program starts (see Notes below). If it doesn't match or if there is no registry entry, the program does not start or you could arrange it so that it starts with only a few demo functions available.
Notes:
Your main form must be shown using vbModal.
You will need to modify the program to change the constant named EMAIL to your e-mail address.
You should change the registration key algorythm. See CalcRegKey in modProtect and Sub Main in modGenKey. The changes should be the same in both places.
Hi there, i tried out your project and it works well. I know this is an old post,i hope i can get a reply. What i wanted to know is instead of numbers for the geygen i wanted to figure out letters from the serial number entered.such as 20 letters in @@@@@-@@@@@-@@@@@-@@@@@ format. this is for a program i have i wish to give others and not abused. thanks
Hi there, i tried out your project and it works well. I know this is an old post,i hope i can get a reply. What i wanted to know is instead of numbers for the geygen i wanted to figure out letters from the serial number entered.such as 20 letters in @@@@@-@@@@@-@@@@@-@@@@@ format. this is for a program i have i wish to give others and not abused. thanks
You can do anything you want with the code. If you wanted to produce letters instead of numbers a simple 1=A 2=B or something more complicated would be easy to do.
Hi ty for the reply, im a beginner in vb here is what i did
Code:
Option Explicit
Public Sub Main()
Dim strLicenseKey As String
Dim lngSerialNum As Long
Const VALID_CHARS = "ABCDEFGHJKLMNPQRTUVWXY"
lngSerialNum = InputBox("Enter user's hard drive serial number")
' This calculation must be the same as the one used in your application
strLicenseKey = CStr(Int(3456 * Sqr(lngSerialNum / 5)))
strLicenseKey = Left$(strLicenseKey, 20)
If Len(strLicenseKey) < 20 Then
strLicenseKey = Left$(VALID_CHARS, 20 - Len(strLicenseKey)) & strLicenseKey
End If
strLicenseKey = Format(strLicenseKey, "@@@@@-@@@@@-@@@@@-@@@@@")
frmGenKey.txtKey = strLicenseKey
frmGenKey.Show vbModal
End Sub
this works to a point i still get 9 numbers at the end and the letters arn't random. i tryed to adapt from another source code, it wouldn't work. see attachment
Please post some of the code you need help with (it makes it easier to help you)
If your problem has been solved then please mark the thread [RESOLVED].
Don't forget to Rate this post
"Pinky, you give a whole new meaning to the phrase, 'counter-intelligence'."-The Brain-
i was thinking about an MD5 hash to calculate the keygen
i got that in the attachment in my previous post. HEH MY BRAIN HURTS LOL
I looks like you don't fully understand how Replace works. What I mean is that your second replace is strLicenseKey = Replace(strLicenseKey, "1", "D"). That's fine but it means that all ones in the key will be replaced by "D" so this line strLicenseKey = Replace(strLicenseKey, "10", "H") and all that follow them will never work since there are no more ones.
Private Sub Command1_Click()
Text1 = GenerateCode()
End Sub
Public Function GenerateCode()
strInputString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
intLength = Len(strInputString)
intNameLength = 20
Randomize
strName = ""
For intStep = 1 To intNameLength
intRnd = Int((intLength * Rnd) + 1)
strName = strName & Mid(strInputString, intRnd, 1)
Next
strName = Format(strName, "@@@@@-@@@@@-@@@@@-@@@@@")
GenerateCode = strName
End Function
now if i could include the serial number and product id shown in the attachment to generate the key i can rest i guess.Ive tried your code and it doesn't seam to work.
sorry about confusement martin. I wanted to take the circled hard drive serial number and productid in the attached image then in my code generate a license key using both. is that possible or do i need to use license key script from hard key license manager for wich i have.
The code is yours to do whatever you want to with it. Currently the code just gets the serial number and generates a registration key from it however there is nothing to stop you from combining the serial number and productid somehow and generating the registration code from the result.
I was wondering where in the code it does the saving the code and such to registry so that it can check if it has been installed? I am trying to understand the program so that I can try to use this idea in VB.NET (Express). If anyone knows of some tutorials or if this has already been done I would love to not have to try to re-invent the wheel.
Attached is a project (actually two projects) that show one way of having the user register his copy of your program. This is the way it works:
The main application displays a registration screen with two options: "Register" and "Request Registration Key".
If the user selects "Register" a new screen is shown that asks the user for his name and tells him that if he continues it will generate an e-mail message to you (via MAPI) and that you will send him the registration key by return e-mail. If he continues, the program gets his hard drive serial number and includes it in the e-mail to you.
Once you receive the registration request email, you use the second project (GenKey) to generate a registration key by way of a simple algorithm that you can change based on the hard drive serial number. Just remember that the algorithm is in both projects and it must be exactly the same in both.
You then send the registration key back to the user and have them enter it in the second part of the registration screen which writes the key to the registry.
When they start the main program again it uses the same algorithm to see if the registration key in the Registry matches the HD serial number. If it matches the program starts (see Notes below). If it doesn't match or if there is no registry entry, the program does not start or you could arrange it so that it starts with only a few demo functions available.
Notes:
Your main form must be shown using vbModal.
You will need to modify the program to change the constant named EMAIL to your e-mail address.
You should change the registration key algorythm. See CalcRegKey in modProtect and Sub Main in modGenKey. The changes should be the same in both places.
I had a look to your 'A Program Registration Scheme' it looks working OK I will try to make it simple to my application.