Hi All,
Does anyone have the sample code to implement the anti-piracy protection like MPA ? What i really need to know is how to retrieve the unique hardware info for a machine and how to generate the confirmation code for that machine. Thanks.
Printable View
Hi All,
Does anyone have the sample code to implement the anti-piracy protection like MPA ? What i really need to know is how to retrieve the unique hardware info for a machine and how to generate the confirmation code for that machine. Thanks.
What hardware information are you looking for? This will get you the hard drives unique serial number (if that is any help).VB Code:
Private Declare Function GetVolumeInformation Lib _ "kernel32.dll" Alias "GetVolumeInformationA" (ByVal _ lpRootPathName As String, ByVal lpVolumeNameBuffer As _ String, ByVal nVolumeNameSize As Integer, _ lpVolumeSerialNumber As Long, lpMaximumComponentLength _ As Long, lpFileSystemFlags As Long, ByVal _ lpFileSystemNameBuffer As String, ByVal _ nFileSystemNameSize As Long) As Long Private Function GetSerialNumber(strDrive As String) As Long Dim SerialNum As Long Dim Res As Long Dim Temp1 As String Dim Temp2 As String Temp1 = String$(255, Chr$(0)) Temp2 = String$(255, Chr$(0)) Res = GetVolumeInformation(strDrive, Temp1, _ Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2)) GetSerialNumber = SerialNum End Function 'Add this code To the Command button or sub routine/function Private Sub Command1_Click() Call MsgBox(GetSerialNumber("C:\")) End Sub
What is usually done is to take machine specific information - Hack gave you a way to do that - then put it into some kind of GUID-like string or other long hex string.
Also, consider just generating a list of GUID's, then have your program check any of them.
Sample code to make a GUID with no input. From allapi.net
Code:
Private Declare Function CoCreateGuid Lib "ole32" (id As Any) As Long
Private Sub Form_Load()
MsgBox "Generated GUID: " + CreateGUID
End Sub
Public Function CreateGUID() As String
Dim id(0 To 15) As Byte
Dim Cnt As Long, GUID As String
If CoCreateGuid(id(0)) = 0 Then
For Cnt = 0 To 15
CreateGUID = CreateGUID + IIf(id(Cnt) < 16, "0", "") + Hex$(id(Cnt))
Next Cnt
CreateGUID = Left$(CreateGUID, 8) + "-" + Mid$(CreateGUID, 9, 4) + "-" + Mid$(CreateGUID, 13, 4) + "-" + Mid$(CreateGUID, 17, 4) + "-" + Right$(CreateGUID, 12)
Else
MsgBox "Error while creating GUID!"
End If
End Function
Thanks guys. My intention is to protect my software by applying one copy one machine, just like MPA. I got pretty good idea from your reply. Thanks a lot.
I am not sure about this, but the unique serial no is changed every time you reformat the Hard disk.
Yes. But if the hardware is changed, then the software has to be reinstalled, just like office XP. Formatting C drive should be considered as hardware change. Anyway, formatting C drive is not a frequent task. If user does so, then he has to get new confirmation key. I actually uses the SN# of C as Machine ID for testing purpose. I think it is simple. Thanks.
I believe it's the volume label that can be/is changed.
The serial # is fixed by the manufacturer.
No, Volume Label is an obvious thing. Even the Serial no gets changed.
Well.
I disagree based on experience - not direct knowledge of formatting. I had to low-level format 20 hard disks because the hardware guy was gone. Talk about boring. At any rate - the serial #'s did not change because we kept inventory based on serial #. I had to enter info about each one - before & after the format & rebuild.
It really doesn't matter. Just my experience. YMMV.
Then it seems that I might be confused in this matter. We had discussed this matter once earlier also, and quite a few of them had the same experience. But It might be that I am confused right now as that post was quite a long time back.
We've also found that on some taiwanese OEM hardware the HDD numbers were the sameQuote:
Originally posted by jim mcnamara
Well.
I disagree based on experience - not direct knowledge of formatting. I had to low-level format 20 hard disks because the hardware guy was gone. Talk about boring. At any rate - the serial #'s did not change because we kept inventory based on serial #. I had to enter info about each one - before & after the format & rebuild.
It really doesn't matter. Just my experience. YMMV.
interesting guys!
But how do the customer get a new valid key?
he calls you, give you the S/N of his HD and you generate one?
Yes, customer needs to contact the software provider. But in stead of directly asking the customer to provide the hardware parameters, the software itself will generate an encoded string based on the specified hardware info. on the user's machine. Customer should not be aware of what' kind of info is collected and how the encoded string is generated. After getting that string, software provider will return the customer a confirmation key to match that encoded string to keep the software running. That's is my understanding.Quote:
he calls you, give you the S/N of his HD and you generate one?
Let me tell you something as annoyed Microsoft user. I hate this product activation garbage. People who play around with their computer quite a lot have to call Microsoft/your company quite a lot. This is definitely annoying.
Use a hardware key instead. That also provides good anti-piracy protection and does not make your customers angry.
Yes, i understand that MPA will cause some problems. But hardware key is also sort of pain . My company's software right now is using hardware key attached to LPT. I got a lot of complain about the key compatible issues with printers. The worst thing is some notebooks even don't have the LPT port, USB port only. From my point of view, it all depends on how critic of the information you collect. I am not going to collect very detail info about the machine. Maybe just the SN of C driver that is hardly changed . Since the users of my software are only small group of people with limited computer knowledge, i think it should work. Anyway, thank you for your suggestion.Quote:
Use a hardware key instead. That also provides good anti-piracy protection and does not make your customers angry.