Jump to content

Custom Registry Functions UDF


wraithdu
 Share

Recommended Posts

@wraithdu

Thanks for update looks perfect now.

RegistryViewer with use _RegFunc.au3

Great!

Icon index changed in win7, unsure about vista:

IF @OSBuild < 5000 Then
_GUIImageList_AddIcon($hImage, @WindowsDir&'\regedit.exe', 7)
_GUIImageList_AddIcon($hImage, @WindowsDir&'\regedit.exe', 8)
Else
_GUIImageList_AddIcon($hImage, @WindowsDir&'\regedit.exe', 3)
_GUIImageList_AddIcon($hImage, @WindowsDir&'\regedit.exe', 4)
EndIf
Link to comment
Share on other sites

RegistryViewer with use _RegFunc.au3

That is awesome...

wraithdu, I found another issue .... I think you may end up hating me...... ;)

On win 7 64 bit (and 2008 according to the link below) _regread on HKEY_CLASSES_ROOT64CLSID is not finding anything.. @error is 1 -- invalid root key..

HKEY_CLASSES_ROOTCLSID does not work..

Everything else under ROOT seems ok with HKEY_CLASSES_ROOT

http://msdn.microsoft.com/en-us/library/aa384253(v=vs.85).aspx

HKEY_CLASSES_ROOT is a merged view of HKEY_LOCAL_MACHINESOFTWAREClasses and HKEY_CURRENT_USERSOFTWAREClasses. Redirected keys in these registry paths are effectively redirected for HKEY_CLASSES_ROOT also. This is also true for reflected keys on systems that support them.

I can read correctly if I am going under "HKEY_LOCAL_MACHINE64SOFTWAREClassesCLSID" and since it reflects to ROOT, i guess that is ok :)

Edited by step887
Link to comment
Share on other sites

@step887

JFX is correct. I'm sure I left that out for a reason, however I can add it in with the next update... buyer beware. If you want to add in JFX's fix for now, go ahead, but also add the HKCR32 spec.

Edited by wraithdu
Link to comment
Share on other sites

  • 2 months later...

Wraithdu,

Been using this all this time and it is solid. Found another issue/judgement call..

_regkeyexists and _regvalueexists was returning 0 if the registry key was there, but there was a permission issue.

_regread is returning @error = 2 - Failed to open source key (@extended contains RegOpenKeyExW return value) @extended = 5 (ERROR_ACCESS_DENIED)

I modified both functions to:

_RegRead($s_key, "") ; try to read default value
$error = @error
$extended = @extended
If $error = 2 And $extended = 5 Then Return SetError(0, $extended, 2)
Switch $error
  Case 1, 2
   ; invalid root key | failed to open key
   Return SetError($error, $extended, 0)
  Case Else
   ; key exists
   Return SetError(0, 0, 1)
EndSwitch

The only reason I used $error and $extended was there was an issue with the script when it was Obfuscated and I used @error and @extended.

Edited by step887
Link to comment
Share on other sites

  • 1 month later...

I tried to make himself - _RegExportToData

If (Not IsArray($ret)) Or ($ret[0] <> 0) Then
        If IsArray($ret) Then
            Return SetError(3, $ret[0], 0)
        Else
            Return SetError(3, 0, 0)
        EndIf
    EndIf

replace it

If IsArray($ret) Then
        If $ret[0] <> 0 Then Return SetError(3, $ret[0], 0)
    Else
        Return SetError(3, 0, 0)
    EndIf
Edited by AZJIO
Link to comment
Share on other sites

  • 1 year later...

it seems RegCopyValue() and _RegWrite() errorour on 3.3.10.2 while working ok on 3.3.8.1

i'm trying to copy default reg value from one key to another with:

_RegCopyValue( $copy_From, "", $copy_To, "" )

but get @error = 3 - Failed to write destination value (@extended contains _RegWrite error code)

@extended = 2 - Failed to open / create destination key (@extended contains RegCreateKeyExW return value)

_RegWrite error code @extended = 5 --> RegOpenKeyEx access denied (error 5)

reproduce code: (it's coping windows default sound scheme to current)

    Switch @OSArch
        Case "X64"
            $OSKey = "64"
        Case "X86"
            $OSKey = ""
    EndSwitch

                      RegWrite("HKEY_CURRENT_USER" & $OSKey & "\AppEvents\Schemes", '', "REG_SZ", '.default')
            $i = 0
            While 1
                $i += 1
                $subKEY_1 = RegEnumKey("HKEY_CURRENT_USER" & $OSKey & "\AppEvents\Schemes\Apps", $i)
                If @error <> 0 Then ExitLoop 1
                $j = 0
                While 1
                    $j += 1
                    $subKEY_2 = RegEnumKey("HKEY_CURRENT_USER" & $OSKey & "\AppEvents\Schemes\Apps\" & $subKEY_1, $j)
                    If @error <> 0 Then ExitLoop 1
                    $copy_From = "HKEY_CURRENT_USER" & $OSKey & "\AppEvents\Schemes\Apps\" & $subKEY_1 & "\" & $subKEY_2 & "\.Default"
                    $copy_To = "HKEY_CURRENT_USER" & $OSKey & "\AppEvents\Schemes\Apps\" & $subKEY_1 & "\" & $subKEY_2 & "\.Current"
                    _RegCopyValue( $copy_From, "", $copy_To, "" )
                    ConsoleWrite("@error = "&@error&"   @extended = "&@extended&@crlf)
                WEnd
            WEnd
Edited by Iczer
Link to comment
Share on other sites

I do not think something can block regwrite so selectively since i'm on XP, i'm don't have AV, firewall have same permissions (verified) for AutoIt3.exe from both 3.3.8.1 and 3.3.10.2 and most impotant (!) if i replace this:

_RegCopyValue( $copy_From, "", $copy_To, "" )

with this:

$value = RegRead($copy_From,"")
$type = @extended
Switch $type
    Case $REG_SZ
        $type = "REG_SZ"
    Case $REG_EXPAND_SZ
        $type = "REG_EXPAND_SZ"
EndSwitch
RegWrite($copy_To, "", $type, $value)

it works perfectly in both 3.3.8.1 and 3.3.10.2

So if _RegCopyValue works in 3.3.8.1 and not in 3.3.10.2, it have to be UDF or realisation of dllcall in 3.3.10.2. i think.

Link to comment
Share on other sites

  • 1 month later...

Hello,

the function regexport doesn't work in my computer.

I create a new using the export from windows :

Func regExport($file, $key)

    Local $tempFile = @TempDir & "\regExportFunction.txt"
    Local $arrayFile, $Return

    if not FileExists($file) Then
        $Return = FileWrite($file, "Windows Registry Editor Version 5.00" &  @CRLF & @CRLF)
        if $Return = 0 Then Return SetError(1,2,0)
    Endif

    RunWait(@ComSpec & " /c " & 'reg export "' & $key & '" "' & $tempFile & '"', "", @SW_HIDE )
    if @error Then Return SetError(@error,0,0)

    $arrayFile = FileReadToArray($tempFile)
    if @error then
        FileWrite($file, "; [" & $key & "]" & @CRLF & "; Key does not exist" & @CRLF & @CRLF)
        Return 1
    endif

    $Return = FileDelete($tempFile)
    if $Return = 0 Then Return SetError(1,1,0)

    For $i = 2 to Ubound($arrayFile) - 1
        FileWrite($file, $arrayFile[$i] &  @CRLF)
        if $Return = 0 Then Return SetError(1,3,0)
    Next

    Return 1

EndFunc
Link to comment
Share on other sites

  • 1 month later...

Just tried running it in the latest AutoIt (3.3.10.0) and got (since it's already defined in constants.au3 which the script includes):

Global Const $REG_QWORD = 11
_RegFunc.au3"(20,29) : error: $REG_QWORD previously declared as a 'Const'.
Edited by LWC
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...