$form1 = GUICreate("Key", 397, 134, 192, 306)
$label1 = GUICtrlCreateLabel("Ключ пользователя :", 12, 18, 103, 17)
$label2 = GUICtrlCreateLabel("Ключ активации :", 16, 54, 98, 17)
$userid = GUICtrlCreateInput("", 120, 15, 268, 21)
$vipkey = GUICtrlCreateInput("", 120, 51, 268, 21)
$button1 = GUICtrlCreateButton("Генерировать Ключ", 6, 87, 183, 34)
$button2 = GUICtrlCreateButton("Копировать в буфер обмана", 201, 87, 183, 34)
GUISetState(@SW_SHOW)
While 1
$nmsg = GUIGetMsg()
Switch $nmsg
Case -3
Exit
Case $button1
GUICtrlSetData($vipkey, _getkey(GUICtrlRead($userid)))
Case $button2
ClipPut(GUICtrlRead($vipkey))
EndSwitch
WEnd
Func _getkey($userid)
$hash = __md5($userid)
Return StringMid($hash, 1, 7) & "-" & StringMid($hash, 9, 7) & "-" & StringMid($hash, 13, 7) & "-" & StringMid($hash, 17, 7) & "-" & StringMid($hash, 21, 7)
EndFunc
Func _uniquehardwareid($iflags = 0)
Local $oservice = ObjGet("winmgmts:\\.\root\cimv2")
If NOT IsObj($oservice) Then
Return SetError(1, 0, "")
EndIf
Local $oitems, $hash, $text, $hw = "", $result = 0
$oitems = $oservice.execquery("SELECT * FROM Win32_ComputerSystemProduct")
If NOT IsObj($oitems) Then
Return SetError(2, 0, "")
EndIf
For $property In $oitems
$hw &= $property.identifyingnumber
$hw &= $property.name
$hw &= $property.skunumber
$hw &= $property.uuid
$hw &= $property.vendor
$hw &= $property.version
Next
$hw = StringStripWS($hw, 8)
If NOT $hw Then
Return SetError(3, 0, "")
EndIf
If BitAND($iflags, 1) Then
$oitems = $oservice.execquery("SELECT * FROM Win32_BIOS")
If NOT IsObj($oitems) Then
Return SetError(2, 0, "")
EndIf
$text = ""
For $property In $oitems
$text &= $property.identificationcode
$text &= $property.manufacturer
$text &= $property.name
$text &= $property.serialnumber
$text &= $property.smbiosmajorversion
$text &= $property.smbiosminorversion
Next
$text = StringStripWS($text, 8)
If $text Then
$result += 1
$hw &= $text
EndIf
EndIf
If BitAND($iflags, 2) Then
$oitems = $oservice.execquery("SELECT * FROM Win32_Processor")
If NOT IsObj($oitems) Then
Return SetError(2, 0, "")
EndIf
$text = ""
For $property In $oitems
$text &= $property.architecture
$text &= $property.family
$text &= $property.level
$text &= $property.manufacturer
$text &= $property.name
$text &= $property.processorid
$text &= $property.revision
$text &= $property.version
Next
$text = StringStripWS($text, 8)
If $text Then
$result += 2
$hw &= $text
EndIf
EndIf
$hash = __md5($hw)
If NOT $hash Then
Return SetError(4, 0, "")
EndIf
Return SetError(0, $result, $hash)
Return SetError(0, $result, "{" & StringMid($hash, 1, 8) & "-" & StringMid($hash, 9, 4) & "-" & StringMid($hash, 13, 4) & "-" & StringMid($hash, 17, 4) & "-" & StringMid($hash, 21, 12) & "}")
EndFunc
Func __md5($sdata)
Local $ret, $hprov, $hhash, $tdata, $error = 1
$hprov = DllCall("advapi32.dll", "int", "CryptAcquireContextW", "ptr*", 0, "ptr", 0, "ptr", 0, "dword", 3, "dword", -268435456)
If (@error) OR (NOT $hprov[0]) Then
Return ""
EndIf
Do
$hhash = DllCall("advapi32.dll", "int", "CryptCreateHash", "ptr", $hprov[1], "uint", 32771, "ptr", 0, "dword", 0, "ptr*", 0)
If (@error) OR (NOT $hprov[0]) Then
$hhash = 0
ExitLoop
EndIf
$hhash = $hhash[5]
$tdata = DllStructCreate("byte[" & BinaryLen($sdata) & "]")
DllStructSetData($tdata, 1, $sdata)
$ret = DllCall("advapi32.dll", "int", "CryptHashData", "ptr", $hhash, "ptr", DllStructGetPtr($tdata), "dword", DllStructGetSize($tdata), "dword", 1)
If (@error) OR (NOT $ret[0]) Then
ExitLoop
EndIf
$tdata = DllStructCreate("byte[16]")
$ret = DllCall("advapi32.dll", "int", "CryptGetHashParam", "ptr", $hhash, "dword", 2, "ptr", DllStructGetPtr($tdata), "dword*", 16, "dword", 0)
If (@error) OR (NOT $ret[0]) Then
ExitLoop
EndIf
$error = 0
Until 1
If $hhash Then
DllCall("advapi32.dll", "int", "CryptDestroyHash", "ptr", $hhash)
EndIf
If $error Then
Return ""
EndIf
Return StringTrimLeft(DllStructGetData($tdata, 1), 2)
EndFunc