1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| Public Declare PtrSafe Function GetVolumeInformation Lib "Kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
Public Const NumProduit = "1DA242EAF2A6EAF11937EE18311CD2FD"
Public Function ValideLicence() As Boolean
Dim Rs As Object, Sn As String, Lic As String, NewLicence As String
Dim Md As New MD5
Set Rs = CurrentDb.OpenRecordset("SELECT * FROM tblDemo;")
If Rs.EOF Then
Rs.AddNew
Rs("N°Produit") = NumProduit
Rs("N°Serie") = Format(Md.DigestStrToHexStr(GetMyMACAddress & SerialDisk & NumProduit), "@@@@@@@@-@@@@@@@@-@@@@@@@@-@@@@@@@@")
Rs("dateinstallation") = Now
Rs("N°Licence") = Format(Md.DigestStrToHexStr(Rs("N°Produit") & Rs("N°Serie") & Rs("dateinstallation")), " @@@@@@@@-@@@@@@@@-@@@@@@@@-@@@@@@@@")
Rs("Premiereinstallation") = True
Rs("Active") = False
Rs.Update
Rs.Requery
End If
If DCount("*", "tblVentes") >= 2 Then
Rs.Edit
Rs("Premiereinstallation") = False
Rs.Update
Rs.Requery
End If
If Rs("Active") = False And Rs("Premiereinstallation") = False Then
Sn = Format(Md.DigestStrToHexStr(GetMyMACAddress & SerialDisk & NumProduit), "@@@@@@@@-@@@@@@@@-@@@@@@@@-@@@@@@@@")
Lic = Format(Md.DigestStrToHexStr(Rs("N°Produit") & Sn & Rs("dateinstallation")), "@@@@@@@@-@@@@@@@@-@@@@@@@@-@@@@@@@@")
Debug.Print Rs("N°Licence"), Lic
NewLicence = InputBox("Code Produit : " & NumProduit & vbCrLf & "Entrez le N° Licence")
If Rs("N°Licence") <> Lic And NewLicence <> Lic Then
MsgBox "blablabla"
Exit Function
Else
MsgBox "blablabla"
Rs.Edit
Rs("Active") = True
Rs("Premiereinstallation") = False
Rs.Update
Rs.Requery
DoCmd.Close acForm, "F_MenuGeneral"
DoCmd.OpenForm "F_MenuGeneral"
End If
End If
If Rs("Active") = True Then
Sn = Format(Md.DigestStrToHexStr(GetMyMACAddress & SerialDisk & NumProduit), "@@@@@@@@-@@@@@@@@-@@@@@@@@-@@@@@@@@")
Lic = Format(Md.DigestStrToHexStr(Rs("N°Produit") & Sn & Rs("dateinstallation")), "@@@@@@@@-@@@@@@@@-@@@@@@@@-@@@@@@@@")
If Rs("N°Licence") <> Lic Then Exit Function
End If
ValideLicence = True
End Function |
Partager