Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Include <_RegFunc.au3>
- $timer1 = TimerInit()
- $sResult1=''
- _RegExportToData($sResult1, 'HKEY_LOCAL_MACHINE\HARDWARE')
- $timer1 = Round(TimerDiff($timer1), 2)
- If MsgBox(4, "", '_RegExportToData : ' & $timer1)=6 Then
- $file = FileOpen(@ScriptDir&'\я _RegExportToData.reg',2)
- FileWrite($file, $sResult1)
- FileClose($file)
- EndIf
- Func _RegExportToData(ByRef $sData, $s_key, $s_val = Default, $fFirstKey = True)
- If Not _RegKeyExists($s_key) Then Return SetError(1, 0, 0)
- Local $data, $err = 0
- If $fFirstKey Then
- If $s_val <> Default Then
- ; exporting only one value
- If Not _RegValueExists($s_key, $s_val) Then
- Return SetError(2, 0, 0)
- EndIf
- ; write base key
- $sData &= @CRLF & "[" & _RegFormatHeader($s_key) & "]" &@CRLF
- $data = _RegRead($s_key, $s_val, True)
- If @error Then
- Return SetError(4, 0, 0) ; unsupported value type
- EndIf
- Switch @extended
- Case $REG_LINK
- ; unsupported value type
- Return SetError(4, 0, 0)
- Case Else
- ; format value
- If $s_val = "" Then $s_val = "@"
- ; write data
- _RegWriteData($sData, $s_val, $data, @extended)
- Return SetError(0, 0, 1)
- EndSwitch
- EndIf
- EndIf
- ; write base key
- $sData &= @CRLF & "[" & _RegFormatHeader($s_key) & "]" &@CRLF
- ; value loop
- Local $i = -1, $val
- While 1
- $i += 1
- $val = _RegEnumValue($s_key, $i)
- If @error Then ExitLoop ; no more values
- $data = _RegRead($s_key, $val, True)
- If @error Then
- ; unsupported value type
- $err = 4
- ContinueLoop
- EndIf
- Switch @extended
- Case $REG_LINK
- ; unsupported value type
- $err = 4
- ContinueLoop
- Case Else
- ; format value
- If $val = "" Then $val = "@"
- ; write data
- _RegWriteData($sData, $val, $data, @extended)
- EndSwitch
- WEnd
- ; key loop
- Local $key
- $i = -1
- While 1
- $i += 1
- $key = _RegEnumKey($s_key, $i)
- If @error Then ExitLoop ; no more keys
- ; recurse
- _RegExportToData($sData, $s_key & "\" & $key, Default, False)
- If @error Then $err = 4 ; catch recursion errors
- WEnd
- Return SetError($err, 0, Number(Not $err))
- EndFunc ;==>_RegExportToData
- Func _RegWriteData(ByRef $sData, $val, $data, $type)
- If $val <> "@" Then $val = '"' & _RegEscape($val) & '"'
- ;
- Switch $type
- Case $REG_NONE
- ; returned as binary
- If Not $data Then
- $sData &= $val & '=hex(0):' &@CRLF
- Else
- $sData &= _RegFormatData($val & '=hex(0):', StringLower($data)) &@CRLF
- EndIf
- Case $REG_SZ
- ; returned as string, not NULL terminated
- $sData &= $val & '="' & _RegEscape($data) & '"' &@CRLF
- Case $REG_EXPAND_SZ
- ; returned as string, not NULL terminated
- If Not $data Then
- $sData &= $val & '=hex(2):00,00' &@CRLF
- Else
- $sData &= _RegFormatData($val & '=hex(2):', StringLower(StringToBinary($data, 2)) & "0000") &@CRLF
- EndIf
- Case $REG_BINARY
- ; returned as binary
- If Not $data Then
- $sData &= $val & '=hex:' &@CRLF
- Else
- $sData &= _RegFormatData($val & '=hex:', StringLower($data)) &@CRLF
- EndIf
- Case $REG_DWORD
- ; returned as dword
- $sData &= $val & "=dword:" & StringLower(Hex($data, 8)) &@CRLF
- Case $REG_DWORD_BIG_ENDIAN
- ; returned as binary
- $sData &= _RegFormatData($val & '=hex(5):', StringLower($data)) &@CRLF
- Case $REG_MULTI_SZ
- ; returned as binary, double NULL terminated
- If Not $data Then
- $sData &= $val & '=hex(7):00,00' &@CRLF
- Else
- $sData &= _RegFormatData($val & '=hex(7):', StringLower($data)) &@CRLF
- EndIf
- Case $REG_RESOURCE_LIST
- ; returned as binary
- If Not $data Then
- $sData &= $val & '=hex(8):' &@CRLF
- Else
- $sData &= _RegFormatData($val & '=hex(8):', StringLower($data)) &@CRLF
- EndIf
- Case $REG_FULL_RESOURCE_DESCRIPTOR
- ; returned as binary
- If Not $data Then
- $sData &= $val & '=hex(9):' &@CRLF
- Else
- $sData &= _RegFormatData($val & '=hex(9):', StringLower($data)) &@CRLF
- EndIf
- Case $REG_RESOURCE_REQUIREMENTS_LIST
- ; returned as binary
- If Not $data Then
- $sData &= $val & '=hex(a):' &@CRLF
- Else
- $sData &= _RegFormatData($val & '=hex(a):', StringLower($data)) &@CRLF
- EndIf
- Case $REG_QWORD
- ; returned as qword
- If Not $data Then
- $sData &= $val & '=hex(b):00,00,00,00,00,00,00,00' &@CRLF
- Else
- $sData &= _RegFormatData($val & '=hex(b):', StringLower(Binary($data))) &@CRLF
- EndIf
- EndSwitch
- EndFunc ;==>_RegWriteFile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement