Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#2249 closed Bug (No Bug)

RegRead(): Unexpected @extended result - possible bug

Reported by: gds2525@… Owned by:
Milestone: Component: AutoIt
Version: 3.3.8.1 Severity: None
Keywords: RegRead Cc:

Description

; RegRead(): Unexpected @extended return for REG_TYPE when
; reading the default value with the data showing (value not set)
;
; Expected return was @extended = 0 (REG_NONE)
; Minimal expectation was @extended = 1 (REG_SZ) because
; Regedit showed 'REG_SZ' when the default value data showed (value not set)
; Note that if you write any value using Regedit, returns @extended = 1
;
; The unexpected return was @extended = 2 (REG_EXPAND_SZ)
;
; Windows XP Pro SP3
; Using Regedit 5.1 b2600 SP3 to view registry test key
;
; Running script from within Scite4AutoIT v3.2.0 Jun 9 2012 00:35:28
; Ran on both Production 3.3.8.1 and Beta 3.3.9.4
; from within scite and it produced the same result.
;
; Create Test Key:
RegWrite("HKLM\SOFTWARE\_AutoItRegTypeReturnTest")

RegRead("HKLM\SOFTWARE\_AutoItRegTypeReturnTest", "")
MsgBox(0, "REG_TYPE", @extended) ; Returns @extended = 2 (REG_EXPAND_SZ Type)

Exit

Attachments (0)

Change History (3)

comment:1 follow-up: Changed 7 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

Hint: Your code sucks. Here's some real code.

Local Const $sKey = "HKCU\SOFTWARE\_AutoItRegTypeReturnTest"

RegWrite($sKey)

RegRead($sKey, "")
MsgBox(0, "REG_TYPE", "Error: " & @error & @CRLF & "Extended: " & @extended)
RegDelete($sKey)

Notice the following:

  • I don't write to HKLM since, you know, you shouldn't write to HKLM unless you want the write redirected on Vista or later.
  • I take the time to clean up the registry so the mess isn't left behind.
  • Check the value of @error since, you know, it's kind of important SINCE AN ERROR OCCURRED.

No bug, code is working as intended.

comment:2 in reply to: ↑ 1 Changed 7 years ago by anonymous

Thanks for the reply ... Not sure you are seeing what i am seeing but

Your code and the minimal code posted return the same thing
(Regardless of HKCU or HKLM)

Yes, i did check the @error value for both which
was also the same and expected ... -1
You're right, I should have included @error in the posted code.

@error -1 worked for me in my working script to prevent trouble
as i was only using RegRead to identify the default value type
of a particular key and whether i could work with it or not.

Constants.au3 defines Global Const $REG_NONE = 0

Microsoft Defines REG_NONE as "No defined value type"
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724884%28v=vs.85%29.aspx

RegRead is erroring out with -1 (unable to open requested value)
RegRead Help File says: @EXTENDED is set to the type of the value

RegRead is returning @error -1, @extended 2 (Global Const $REG_EXPAND_SZ = 2)

Dont see how the @extended return is appropriate under these conditions.

Unless: You look at it like ... AutoIt 'said' it would be wrong (@error -1)
so i guess it can put anything it wants into @extended, we were warned.

Shouldn't it return something more appropriate like 0 = $REG_NONE ?

Yes / No ? ... I Have nothing more to add to this so this closes it for me.

comment:3 Changed 7 years ago by Valik

Err, @extended is documented for successful calls. Notice that it is not documented for failures.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.