find your license code for Adobe Acrobat

Share your advanced PureBasic knowledge/code with the community.
normeus
Enthusiast
Enthusiast
Posts: 472
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

find your license code for Adobe Acrobat

Post by normeus »

I have multiple computers with Adobe Acrobat 10 , one of the computers died and I needed to move Adobe's license to a new computer.
This program will search for Adobe's license database and might find it on your computer. It didn't find it on one of my computers which is strange because they are the same version of Adobe Acrobat. Anyway see if this program is useful to you.

Code: Select all

; get license for Adobe Acrobat x and xi display on screen and offer to copy to clipboard
; you'll get computer name software version and license number so you can keep for your records
; sometimes it does not work because the Adobe database is empty and I dont know why
; codeAdobeKey: from http://superuser.com/questions/784578/find-key-of-installed-and-activated-instance-adobe-acrobat-professional-without
;GetRegistryRunEntries: it might be @PB code from http://www.purebasic.fr/english/viewtopic.php?p=437244&sid=30aaeafe926be49ed923fa01fe0acdfc#p437244
; I do enjoy testing for enableExplicit, turning it on then if it was off to begin with, turn it off 

CompilerIf #PB_Compiler_EnableExplicit 
  Define testenableexplicit=1
CompilerElse  
  Define testenableexplicit=0
  EnableExplicit
CompilerEndIf



Procedure.s codeAdobeKey(keyIn.s)
  Protected Dim adobeCipher.s(24)
  Protected keyOut.s,k.s,j.s
  Protected i
  
  AdobeCipher( 0) = "0000000001"
  AdobeCipher( 1) = "5038647192"
  AdobeCipher( 2) = "1456053789"
  AdobeCipher( 3) = "2604371895"
  AdobeCipher( 4) = "4753896210"
  AdobeCipher( 5) = "8145962073"
  AdobeCipher( 6) = "0319728564"
  AdobeCipher( 7) = "7901235846"
  AdobeCipher( 8) = "7901235846"
  AdobeCipher( 9) = "0319728564"
  AdobeCipher(10) = "8145962073"
  AdobeCipher(11) = "4753896210"
  AdobeCipher(12) = "2604371895"
  AdobeCipher(13) = "1426053789"
  AdobeCipher(14) = "5038647192"
  AdobeCipher(15) = "3267408951"
  AdobeCipher(16) = "5038647192"
  AdobeCipher(17) = "2604371895"
  AdobeCipher(18) = "8145962073"
  AdobeCipher(19) = "7901235846"
  AdobeCipher(20) = "3267408951"
  AdobeCipher(21) = "1426053789"
  AdobeCipher(22) = "4753896210"
  AdobeCipher(23) = "0319728564"
  
  
  For i = 0 To 23
    If ( Mod(i,4) = 0 And i > 0 )
      keyOut= keyOut + "-"
    EndIf
    j = Mid(keyIn,i+1,1)
    k = Mid(AdobeCipher(i),Val(j)+1,1)
    keyOut= keyOut + k
  Next
  ProcedureReturn keyOut
EndProcedure

Procedure.s GetRegistryRunEntries(OpenKey,SubKey$)
  Protected savename.s,hkey.s,entries,wValue$,lwvalue,wData$,lwdata,res,tmp,a
  If RegOpenKeyEx_(OpenKey,@SubKey$,0,#KEY_QUERY_VALUE|#KEY_ENUMERATE_SUB_KEYS,@hKey)=#ERROR_SUCCESS
    entries=-1
    Repeat
      wValue$=Space(999) : lwValue=255 : wData$=Space(999) : lwData=255 : entries+1
      res=RegEnumValue_(hKey,entries,@wValue$,@lwValue,0,@tmp,@wData$,@lwData)
    Until res<>#ERROR_SUCCESS
    entries-1
    If entries>-1
      For a=0 To entries
        wValue$=Space(999) : lwValue=255 : wData$=Space(999) : lwData=255
        If RegEnumValue_(hKey,a,@wValue$,@lwValue,0,@tmp,@wData$,@lwData)=#ERROR_SUCCESS
          If wValue$ = "ComputerName"
            savename =wData$
            Debug wValue$+" = "+wData$
          EndIf
        EndIf
      Next
    EndIf
  EndIf
  ProcedureReturn savename
EndProcedure

UseSQLiteDatabase()

Define fn.s="C:\Program Files (x86)\Common Files\Adobe\Adobe PCD\cache\cache.db"

Define adobeKey.s="",CName.s=""
Define adobeVer.s="", dbKey.s,dbVal.s

CName=GetRegistryRunEntries(#HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\")
;open database
If FileSize(fn)
  If OpenDatabase(0, fn, "", "",#PB_Database_SQLite )
    If DatabaseQuery(0, "SELECT value,key FROM domain_data WHERE key = 'SN' or key = 'PPAPP' or key LIKE 'Acrobat_Base_%'")
      
      While NextDatabaseRow(0)
        dbval=GetDatabaseString(0, 0)
        dbkey=GetDatabaseString(0, 1)
        If dbKey = "SN":adobeKey = dbVal:EndIf
        If dbkey = "PPAPP":adobeVer = dbVal:EndIf
        If Left(dbkey,13) =  "Acrobat_Base_":
          If adobeVer < dbkey
            adobeVer = dbkey
          EndIf
        EndIf
      Wend
      FinishDatabaseQuery(0)
    EndIf
    CloseDatabase(0)
  EndIf
  Else
    MessageRequester("Database File Not Found", fn)
    End
EndIf

adobekey = codeAdobeKey(adobekey)


If adobekey = "0512-4807-7084-2153-5287-3140" 
  adobeKey = "DIDNT FIND KEY"
EndIf
adobeVer= ReplaceString(adobeVer, "Acrobat_Base_", "Acrobat Subscription ")

If MessageRequester( cname+ " Save To clipboard?", adobeVer+" : "+adobeKey,#PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes 
  SetClipboardText(cname + ":" + adobeVer +" - " + adobeKey )
EndIf
; this is part of my enable explicit test 
If testenableexplicit = 1
Else
  DisableExplicit
EndIf  
Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari