tanveerhabib
Programmer
Hello I have an application built in VFP which generates user ID from computer hardware. My question is how can I create a license generator for putting a valid license in the software. thank.s
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
**MakeGUID
Private pGuid
Local lcData1, lc1st4, lc2nd4, lc3rd4, lc4th4, lc5th4, lcData5, lc6th4, lc7th4, lcGuid
Store "" To m.lc1st4, m.lc2nd4, m.lc3rd4, m.lc4th4, m.lc5th4, m.lc6th4, m.lc7th4, m.lcData1, m.lcData5
* -- declare external function
Declare Integer CoCreateGuid In OLE32.Dll String @pGuid
* -- Initialize the buffer that will hold the GUID with nulls
pGuid = Replicate(Chr(0),17)
* -- Call CoCreateGuid
If CoCreateGuid(@m.pGuid) = 0 && success
* -- Store the first eight characters of the GUID in data1
lcData1 = Right(Transform(strtolong(Left(m.pGuid,4)),"@0"),8)
lc1st4 = Left(m.lcData1,4)
lc2nd4 = Substr(m.lcData1,5,4)
* -- Store the first group of four characters of the GUID in data2
lc3rd4 = Right(Transform(strtolong(Substr(m.pGuid,5,2)),"@0"),4)
* -- Store the second group of four characters of the GUID in data3
lc4th4 = Right(Transform(strtolong(Substr(m.pGuid,7,2)),"@0"),4)
* -- Store the third group of four characters of the GUID in data4
lc5th4 = Right(Transform(strtolong(Substr(m.pGuid,9,1)),"@0"),2) + Right(Transform(strtolong(Substr(m.pGuid,10,1)),"@0"),2)
* -- Initialize data5 to a null string
lcData5 = ""
* -- Convert the final 12 characters of the GUID and store in data5
For lnGuidLen = 1 To 6
lcData5=m.lcData5+Right(Transform(strtolong(Substr(m.pGuid,10+m.lnGuidLen,1))),2)
Endfor
* -- Check the length of data5. If less than 12, the final 12-len(data5) characters are '0'
If Len(m.lcData5) < 12
lcData5=m.lcData5+Replicate("0",12-Len(m.lcData5))
Endif
lc6th4 = Left(m.lcData5,4)
lc7th4 = Substr(m.lcData5,5,4)
* -- Assemble the GUID into a string
lcGuid = m.lc1st4+"-"+m.lc2nd4+"-"+m.lc3rd4+"-"+m.lc4th4+"-"+m.lc5th4+"-"+m.lc6th4+"-"+m.lc7th4
Endif
* -- Done with the call to CoCreateGuid, so clear the DLLs from memory
Clear Dlls
lcGuid = controldigit(m.lcGuid)
Return m.lcGuid
Endfunc
*******************
Function strtolong
* -- Passed: 4-byte character string (lcLongstr) in low-high ASCII format
* -- Returns: long integer value
* -- Example:
* -- m.longstr = "1111"
* -- m.longval = strtolong(m.longstr)
Parameters lcLongstr
Local lnByte As Number, ;
lnRetval As Number
lnRetval = 0
For lnByte = 0 To 24 Step 8
lnRetval = m.lnRetval + (Asc(m.lcLongstr) * (2^m.lnByte))
lcLongstr = Right(m.lcLongstr, Len(m.lcLongstr) - 1)
Next
Return m.lnRetval
Endfunc
*!* 19-9-2015 10:45:03
*!* Purpose : to implent a 37-check
*!*
Function controldigit
Parameters tcGuid
Local lcGuid As String, ;
lcResult As String, ;
lnDigit As Number, ;
lnResult As Number, ;
lnSum As Number
lcGuid = Alltrim(m.tcGuid)+"-"
lnSum = 0
For lnDigit = 1 To Len(m.tcGuid)
lnSum = m.lnSum + Asc(Substr(m.tcGuid,m.lnDigit,1))
Endfor
lnResult = Mod(m.lnSum,37)
lcResult = Padl(Transform(m.lnResult),2,'0')
Return m.lcGuid + Transform(m.lcResult)
Endfunc