Jump to content

my function doesn't get the requested value


Go to solution Solved by orbs,

Recommended Posts

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
Link to comment
Share on other sites

  • Solution

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

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Windows 64-bit introduces many aspects of registry/filesystem redirection. start your reading here:

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

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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)

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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.

Link to comment
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>>

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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...