Récupérer la clef cd windows d un pc distant

Description

comme son titre l' indique ce code sert a recupérer la clef cd xp d un poste distant

la vrai clef cd

pour une recupe de la local ne mettre que l adresse ip de son ordi et ne pas remplir les autres champs tel que login et mdp
ce code n est pas entierement de moi je l ai juste modifier pour recupérer a distance

Source / Exemple :


Private Sub Command1_Click()
On Error Resume Next
Dim bProductKey()
Dim bKeyChars(24)
Dim ilByte
Dim nCur
Dim sCDKey
Dim ilKeyByte
Dim ilBit
strUser = Text1.Text
strPassword = Text2.Text
strcomputer = Text3.Text
ReDim Preserve bProductKey(14)
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set Namespace = objLocator.ConnectServer(strcomputer, "\root\Default", strUser, strPassword)
Const HKEY_LOCAL_MACHINE = &H80000002
Set objReg = Namespace.Get("StdRegProv")
'endroit ou se trouve la clef
strKeyPath = "SOFTWARE\MICROSOFT\Windows NT\CurrentVersion"
strValueName = "DigitalProductId"
objReg.GetBinaryValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, arrvalues
If objReg.GetBinaryValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, arrValueData) = 0 Then
For ilByte = 52 To 66
bProductKey(ilByte - 52) = arrValueData(ilByte)
Next
'caractere possible dans la clef cd
bKeyChars(0) = Asc("B")
bKeyChars(1) = Asc("C")
bKeyChars(2) = Asc("D")
bKeyChars(3) = Asc("F")
bKeyChars(4) = Asc("G")
bKeyChars(5) = Asc("H")
bKeyChars(6) = Asc("J")
bKeyChars(7) = Asc("K")
bKeyChars(8) = Asc("M")
bKeyChars(9) = Asc("P")
bKeyChars(10) = Asc("Q")
bKeyChars(11) = Asc("R")
bKeyChars(12) = Asc("T")
bKeyChars(13) = Asc("V")
bKeyChars(14) = Asc("W")
bKeyChars(15) = Asc("X")
bKeyChars(16) = Asc("Y")
bKeyChars(17) = Asc("2")
bKeyChars(18) = Asc("3")
bKeyChars(19) = Asc("4")
bKeyChars(20) = Asc("6")
bKeyChars(21) = Asc("7")
bKeyChars(22) = Asc("8")
bKeyChars(23) = Asc("9")
For ilByte = 24 To 0 Step -1
nCur = 0
For ilKeyByte = 14 To 0 Step -1
'Step through each byte in the Product Key
nCur = nCur * 256 Xor bProductKey(ilKeyByte)
bProductKey(ilKeyByte) = Int(nCur / 24)
nCur = nCur Mod 24
Next
sCDKey = Chr(bKeyChars(nCur)) & sCDKey
If ilByte Mod 5 = 0 And ilByte <> 0 Then sCDKey = "-" & sCDKey
Next

    Label1.Caption = sCDKey
    
    End If
End Sub

Codes Sources

A voir également