Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Perl registry reflection – How?

by roteme (Acolyte)
on Mar 19, 2012 at 06:33 UTC ( [id://960367]=perlquestion: print w/replies, xml ) Need Help??

roteme has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I would like to check if some program installed on Win machine.

I wrote the following simple code to check it:

use Win32::Registry; # $SERVER_PLATFORM = x86 or x64 - i set it before in other function if ($SERVER_PLATFORM eq "x86") { $Registry = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{ +5C65E4AB-BDF9-4784-968F-2FC6151B1637}'; } else { $Registry = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{ +B2AE58F9-BF87-4345-9A48-B4C855A484FD}'; } if ($HKEY_LOCAL_MACHINE->Open($Registry,$hkey) ) { print "Found Software YYY installed on the machine\n"; } else { print "Software YYY does not installed on the machine\n"; }

The above code successfully run on 32 bit machine.

On 64 bit machine the product ID exist only under the following registry path:

SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B2AE58F9-BF87-4345-9A48-B4C855A484FD}

And doesn't exist under the default registry path (Wow6432Node folder):

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{B2AE58F9-BF87-4345-9A48-B4C855A484FD}

How I could make my program to read registry values on x64 bit machine from SOFTWARE\Microsoft\… and not from Wow6432Node folder

Please advice

Thanks

Replies are listed 'Best First'.
Re: Perl registry reflection – How?
by Anonymous Monk on Mar 19, 2012 at 06:59 UTC

    Just do it?

    $ echo %PROCESSOR_ARCHITECTURE% x86
      The issue isn't to recognize the PROCESSOR_ARCHITECTURE - that i did in previous function in my full code and set $SERVER_PLATFORM accordingly - the issue/question is how can I control the reading of the Registry key in x64 machine: from: HKEY_LOCAL_MACHINE\SOFTWARE or: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node

        Um, that is what just doesn't make any sense whatsoever. Its like saying I can tie my left shoe, how can I tie my right shoe?

        You have the code right there, change $Registry in the conditional to the 64 value, and you're done.

Re: Perl registry reflection – How?
by wwe (Friar) on Mar 21, 2012 at 11:37 UTC

      I run Perl exe which compile by Cava Packager x86.

      As i wrote, On 64 bit machine i can't read registry from HKEY_LOCAL_MACHINE\SOFTWARE (x64 registry path) - Only from HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node

      Can someone give me an example how to implement it - read key from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall on x64 machine.

      Thanks

        Hi Monks,

        Can you please advice on my question above.

        Thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://960367]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-18 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found