Sign in to follow this  
Followers 0
gulloom

Problems reading registry GUID with RegEnumVal

7 posts in this topic

Hi,

I am using RegEnumVal to read all Keys from the uninstall registry in order to find the GUID of an installed application.

The problem is that RegEnumVal does not read the keys in {}.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{20D04FE0-3AEA-1069-A2D8-08002B30309D} ==> NOT BEING READ

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ATI Display Driver ==> BEING READ SUCCESSFULLY

Can anyone help?

Thans in advance.

Share this post


Link to post
Share on other sites



The problem lies elsewhere, this returns all uninstall subkeys, including those in squiggly brackets.

Dim $keys[1]

for $i = 1 to 1000
$reg = RegEnumKey ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" , $i)
if $reg = "" Then
    ExitLoop
Else
    _ArrayAdd($keys , $reg)
EndIf
Next
   _ArrayDelete ($keys , 0)
   _ArrayDisplay ($keys)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

@iamtheky

You are sure a bear for punishment with that damn array.au3 file and specifying 1000 as the max for $i. All you have to do is put it into a While/WEnd loop and check for @Error

This works, just replace the MsgBox() with whatever you want to do.

$sRegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

$iKey = 1
While 1
    $sHold = RegEnumKey($sRegKey, $iKey)
    If @Error Then ExitLoop
    $iKey += 1
    If NOT StringRegExp($sHold, "^\{[-[:xdigit:]]+\}$") Then ContinueLoop;;  We only want the ones that use a Guid.  If you want all of them then remove this line
    ;;At this point $sHold contains the ProductGUID.  If you want to actually only get those that have a ProductGUID value change "InstallLocation" to "ProductGuid" below
    $sCur_Val = RegRead($sRegKey & $sHold, "InstallLocation")
    If NOT @Error Then
        MsgBox(4096, "Result", $sHold & @CRLF & $sCur_Val, 3)
    EndIf
WEnd

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

its just at hand as i am playing with some larger fun. Those are copy and paste jobs for the most part and I fully expected a one line SRE to come and win the shortest solution.

I suppose nicely worded whiles would also be preferred over my

$i = 1 to 1 step 0
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

That's an interesting bit of code, won't do much but interesting.

That array.au3 file is getting badly over-used around here and much of it is really obsolete and slow. By that I mean we do have some better methods to create arrays now.

The For $i = 1 to 1000 is a natural failure if I have more than 1000 entries in a key. Not too likely but it could happen and especially in a key like uninstall


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Indeed.

see

for an implementation of the for 1 to 1 step 0. It loops forever (until a condition is met inside to exitloop). But as i mentioned it seems a nicely worded while statement would do the same.

IF @Error could certainly stand to be a more common thought in my writing, and can always use the reminder.

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Error checking is always good and not enough people do it. Here are a couple of functions for you to play with, I just slapped them together to show you another way of dimming the arrays which will be much faster than your _ArrayAdd() and _ArrayDelete() and without testing I can pretty much bet it's faster than ReDim as well.

$sRegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

;; Just for fun lets Dim an array

Dim $aArray[_Reg_CountSubKeys($sRegKey)][3]

MsgBox(4096, "Result", UBound($aArray) & " x " & UBound($aArray, 0))

Func _Reg_CountSubKeys($s_Key)
    Local $iKey = 1
    While 1
        $sHold = RegEnumKey($s_Key, $iKey)
        If @Error Then ExitLoop
        $iKey += 1
    WEnd
    Return ($iKey)
EndFunc   ;==>_Reg_CountSubKeys

Func _Reg_CountVals($s_Key)
    Local $iKey = 1
    While 1
        $sHold = RegEnumVal($s_Key, $iKey)
        If @Error Then ExitLoop
        $iKey += 1
    WEnd
    Return ($iKey)
EndFunc   ;==>_Reg_CountVals

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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