Sign in to follow this  
Followers 0
colombeen

my function doesn't get the requested value

9 posts in this topic

#1 ·  Posted (edited)

Hi guys, I have the following problem.

I got a function from the forum to get info from the uninstall location in the windows registry. I've changed it a bit but when i run it, it goes through alot of the values, but it doesn't pass the one that I want. the error number I get is -1 on the RegRead (I've tried the same with the original but it fails)

my function here : 

;========================================================================;
; Function: Get info from uninstall section in the registry
;========================================================================;
Func _UninstallGetInfo($varSearch, $varReturnKey = "DisplayName")
    $varLocation            =   "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
    $intEval                =   1
    While 1
        $varResult          =   ""
        $varTemp            =   ""
        $varCurrent         =   RegEnumKey($varLocation, $intEval)
        If @error = 0 Then
            $varRegKey      =   $varLocation & $varCurrent
            $varTemp        =   RegRead($varRegKey, "DisplayName")

            If StringRegExp($varTemp, ".*" & $varSearch & ".*") Then
                $varResult  =   RegRead($varRegKey, $varReturnKey)
                If @error = 0 Then
                    Return $varResult
                Else
                    Return False
                EndIf
                ExitLoop
            EndIf
        Else
            ExitLoop
        EndIf
        $intEval            +=  1
    WEnd
    Return False
EndFunc ; _UninstallGetInfo

And here's the way that I call it : 

$test = _UninstallGetInfo("Belgium e-ID", "DisplayVersion")
MsgBox(0, "test", $test)

I've used a MsgBox to see every value it checked and this one just doesn't go through the loop : 

Knipsel.PNG

The function exits on $intEval 190 if I'm not mistaken.

Anyone who can help me out? 

If you would need the software that I'm checking for in the registry, you can find it on http://eid.belgium.be

Edited by colombeen

Share this post


Link to post
Share on other sites



a quick shot in the dark: if you are using 64-bit OS, change HKLM to HKLM64. any difference?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

what the hell... I never knew that that even existed... I always used to check for Wow6432Node but never checked HKLM64

Now it found the value that I wanted but I have another question... if I need HKLM64 to find the value in HKLMSoftwareMicrosoftWindowsCurrentVersionUninstall, where did the function look when I used the normal HKLM?

And if my OS would have been a 64 bit WinXP... would I have to do the same thing? I just don't get in which case I have to use HKLM64

Edited by colombeen

Share this post


Link to post
Share on other sites

And if my OS would have been a 64 bit WinXP... would I have to do the same thing? I just don't get in which case I have to use HKLM64

 

read @OSArch to determine if you need to use HKLM or HKLM64 (also for HKCU or HKCU64)

Share this post


Link to post
Share on other sites

yeah but like with my problem here, what if the software is in the HKLM location instead of the HKLM64 on a 64 bit system. I would have to check both to be sure. I'm just not sure how to add that to my function without writing alot of code extra.

Share this post


Link to post
Share on other sites

what you get in HKLM is a filtered view of the HKLM64 (if you are on a 64-bit OS, that is). you are quite safe using HKLM64.

perhaps a different approach will ease your mind: this is by using WMI (i'm not sure how it's different, but it's not a direct registry reading):

'?do=embed' frameborder='0' data-embedContent>>

Share this post


Link to post
Share on other sites

Thx for all the help :-)

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