Lexikos wrote:
What sort of comparison checks? Format is not relevant for numerical comparisons such as regvalue != 0x1 or regvalue > 123. The expression (0 = 0x0000) is always true.
I take a pre- and post-installation snapshot with RegShot, and after uninstalling a program I go over the log using AHK. My script checks if the log entries (files or registry values) still exist, and if so whether they are the same as in the log. The log shows these values the way they appear in regedit, so comparisons for REG_BINARIES and REG_DWORD entries fail unless I first adjust RegRead (or RegShot) output.
Quote:
There are ways to do what you want without looping:
The loop is to get the type (a_LoopRegType) for the value. That's how AHK's help file example (for RegRead) suggests to determine the type for a registry entry.
edit1: sorry, the 'redundant' loop i referred to in my original post was the reg loop that loops through a key to get type for one value, but i realized the loop you referred to was different, and your method's definately better - thanks for the improvement.
From help file:
Code:
RegKeyType(RootKey, SubKey, ValueName) ; This function returns the type of the specified value.
{
Loop, %RootKey%, %SubKey%
if (A_LoopRegName = ValueName)
return A_LoopRegType
return "Error"
}
Thank you for the code. The alternate method was three times faster (in a single benchmark I ran), so I replaced my original code with it:
Code:
regvalue := "0x0123"
; Format integer as hexadecimal, padding with 0 up to 8 digits.
VarSetCapacity(display,20)
DllCall("msvcrt\sprintf", "str", display, "str", "0x%08x", "uint", regvalue)
MsgBox % display
; Alternate method.
SetFormat, IntegerFast, H
MsgBox % "0x" SubStr("00000000" SubStr(regvalue+0, 3), -7)
This method doesn't appear to work for longer strings.<snip>
edit2: works great, sorry, my bad applying the code initially. Thanks again.
Code:
;regvalue := "ABCDEF"
; Insert a space every two characters (except at the end).
MsgBox % RegExReplace(regvalue, "..(?=.)", "$0 ")
To your overall point though: I suppose I was too quick to judge AHK's RegRead format. I thought RegShot logs were more correct because that's how the registry values appear (visually) in regedit, but I suppose I need to change my If-statements to compare the underlying values of each representation rather than their forms.