Sign in to follow this  
Followers 0
Laymanball

Enum Value Data in Registry

2 posts in this topic

#1 ·  Posted (edited)

For enumerate keyvaluedata in registry

add include script "RegEnumValData.au3"

#include-once
Global $keyname = ""
Global $instance = 0
Global $output = ""
Func _RegEnumValData($keyname)
    Do
        $instance += 1
        Local $rnv = RegEnumVal($keyname, $instance)
        Local $rr = RegRead($keyname, $rnv)
        If @error Then ExitLoop
                $output = $output&$rnv&"="&$rr&@CRLF
        
    Until $rnv = ""
        Return $output
EndFunc

------------------------------------------------------------------

syntax: _RegEnumValData([keyname])

run sample script

#include "RegEnumValData.au3"
$keyname = "HKLMSOFTWAREMicrosoftWindows NTCurrentVersion"
MsgBox(0,$keyname, _RegEnumValData($keyname))

------------------------------------------------------------------------------------------------

Select Regread Enumerate ValueName & ValueData

#NoTrayIcon

Opt("MustDeclareVars", 1)

Global $keyname1, $valuename1, $keyname2, $valuename2, $keyname3, $valuename3
Func _SelectEnumRegRead($keyname1, $valuename1, $keyname2, $valuename2, $keyname3="", $valuename3="")
    Local $instance = 0
    Do
        $instance += 1
        Local $rek1 = RegEnumVal($keyname1, $instance)
        Local $rek2 = RegEnumVal($keyname2, $instance)
        Local $rek3 = RegEnumVal($keyname3, $instance)
        If @error Then ExitLoop

        Select
            Case StringInStr($rek1, $valuename1)
                Local $ret1 = $valuename1&"="&RegRead($keyname1, $rek1)&@CRLF
        EndSelect

        Select
            Case StringInStr($rek2, $valuename2)
                Local $ret2 = $valuename2&"="&RegRead($keyname2, $rek2)&@CRLF
        EndSelect

        Select
            Case StringInStr($rek3, $valuename3)
                Local $ret3 = $valuename3&"="&RegRead($keyname3, $rek3)&@CRLF
        EndSelect
    Until False

        Return $ret1&$ret2&$ret3
EndFunc

;syntax: _SelectEnumRegRead([keyname1, $valuename1], [$keyname2, $valuename2], [$keyname3, $valuename3])

$keyname1 = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon"
$valuename1 = "DefaultUserName"
$keyname2 = "HKEY_LOCAL_MACHINEHARDWAREDESCRIPTIONSystemCentralProcessor0"
$valuename2 = "ProcessorNameString"
$keyname3 = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersion"
$valuename3 = "ProductName"

Local $sTable = _SelectEnumRegRead($keyname1, $valuename1, $keyname2, $valuename2, $keyname3, $valuename3)
MsgBox(64, "Operate System Info", $sTable)

----------------------------------------------------------

Multi RegWrite & RegDelete

Global $keyname = "HKLMSOFTWAREMicrosoftWindowsCurrentVersion"
Global $valuename[3]=["Zone1","Zone2","Zone3"]
Global $valuedata[3]=["Data1","Data2","Data3"]

RegWriteTest()
Func RegWriteTest()
    For $i = 0 To 2
        RegWrite($keyname, $valuename[$i], "REG_SZ", $valuedata[$i])
    Next
    $output = ""
    For $i = 0 To 2
       $output = $output&RegRead($keyname, $valuename[$i])&@CRLF
   Next
       MsgBox(0, "Report: Data to write (before)", "Data of keypath: "&$keyname&@CRLF&@CRLF&$output)
    RegDeleteTest()
EndFunc

Func RegDeleteTest()
    $btn = MsgBox(36, "Conform delete all valuedata", "Do you wanted to delete?")
    If $btn = 7 Then Exit
    For $i = 0 To 2
        RegDelete($keyname, $valuename[$i])
    Next
    $output = ""
    For $i = 0 To 2
        $output = $output&RegRead($keyname, $valuename[$i])&@CRLF
    Next
        If $output = @error Then
            MsgBox(48, "Error: Cannot delete all data (after)===", $output)
        Else
            MsgBox(64, "Report: Data to all delete(after)===", "Delete all data complete")
        EndIf
EndFunc

------------------------------------------------------------------------------------------------------------

Select to RegWrite in line ValueName

Global $keyname = "HKLMSOFTWAREMicrosoftWindowsCurrentVersion"
Global $valuename[5]=["Zone1","Zone2","Zone3","Zone4","Zone5"]
Global $valuedata[5]=["Data1","Data2","Data3","Data4","Data5"]
Global $keyname = "HKLMSOFTWAREMicrosoftWindowsCurrentVersion"
Global $valuedata1 = "NewData1"
Global $valuedata4 = "NewData4"
Global $i = 0

RegWriteTest()
Func RegWriteTest()
    For $i = 0 To 4
        RegWrite($keyname, $valuename[$i], "REG_SZ", $valuedata[$i])
    Next
    $output = ""
    For $i = 0 To 4
       $output = $output&RegRead($keyname, $valuename[$i])&@CRLF
   Next
       MsgBox(0, "Report: Data to write (before)", "Data of keypath: "&$keyname&@CRLF&@CRLF&$output)
    SelectEnumRegWrite()
EndFunc

Func SelectEnumRegWrite()
    Do
        $i += 1
        $rev = RegEnumVal($keyname, $i)
        If @error Then ExitLoop
        Switch $rev
            Case "zone1"
                RegWrite($keyname, $rev, "REG_SZ", $valuedata1)
            Case "zone4"
                RegWrite($keyname, $rev, "REG_SZ", $valuedata4)
        EndSwitch
    Until $rev = ""
    $output = ""
    For $i = 0 To 4
       $output = $output&RegRead($keyname, $valuename[$i])&@CRLF
    Next
       _wait()
       MsgBox(0, "Report: NewData to select write (after)", "Data of keypath: "&$keyname&@CRLF&@CRLF&$output)
    RegDeleteTest()
EndFunc

Func RegDeleteTest()
    $btn = MsgBox(36, "Conform delete all valuedata", "Do you wanted to delete?")
    If $btn = 7 Then Exit
    _wait()
    For $i = 0 To 4
        RegDelete($keyname, $valuename[$i])
    Next
    $output = ""
    For $i = 0 To 4
        $output = $output&RegRead($keyname, $valuename[$i])&@CRLF
    Next
        If $output = @error Then
            MsgBox(48, "Error: Cannot delete all data (after)===", $output)
        Else
            MsgBox(64, "Report: Data to all delete(after)===", "Delete all data complete")
        EndIf
EndFunc

Func _wait()
    For $i = 5 To 1 Step -1
        ToolTip("Please wait.. [ "&$i&" ] sec", 410, 400)
        Sleep(1000)
    Next
        ToolTip("")
    ProgressOn("", "", "", 350, 350)
    For $i = 0 To 100
        ProgressSet($i, "", "Loading.. "&$i&" %")
        Sleep(Random(0, 50, 1))
    Next
        Sleep(500)
        ProgressOff()
EndFunc

-----------------------------------------------------------------

Download:Program Registry Manager & SourceCode Click here

Posted Image

Edited by Laymanball

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Thus will be better:

#include-once
; #INDEX# =======================================================================================================================
; Title .........: _RegEnumValData()
; AutoIt Version.: 3.3.8.0
; Language.......:
; Description ...: Enumerate keyvaluedata in registry.
; Author ........: Laymanball
; Modified ......: jscript
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
; _RegEnumValData()
; ===============================================================================================================================

; #INTERNAL_USE_ONLY# ===========================================================================================================
; ===============================================================================================================================

; #VARIABLES# ===================================================================================================================
; ===============================================================================================================================

; #FUNCTION# ====================================================================================================================
; Name ..........: _RegEnumValData
; Description ...:
; Syntax ........: _RegEnumValData($sKeyName)
; Parameters ....: $sKeyName            - A string value.
; Return values .: Keyvalue data.
; Author ........: Laymanball
; Modified ......: jscript
; Remarks .......:
; Related .......:
; Link ..........: http://www.autoitscript.com/forum/topic/136511-enum-value-data-in-registry/page__view__findpost__p__954114
; Example .......: _RegEnumValData( $sKeyName )
; ===============================================================================================================================
Func _RegEnumValData($sKeyName)
    Local $iCount, $sRegEnumVal, $sRegRead, $sRet

    Do
        $iCount += 1
        Local $sRegEnumVal = RegEnumVal($sKeyName, $iCount)
        Local $sRegRead = RegRead($sKeyName, $sRegEnumVal)
        $sRet &= $sRegEnumVal & "=" & $sRegRead & @CRLF
        If @error Then ExitLoop
    Until $sRegEnumVal = ""

    Return $sRet
EndFunc   ;==>_RegEnumValData

Regards,

João Carlos.

Edited by jscript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0