Anthony Okusanya wrote:

> Hi all
>       I have a utility I wrote using ActivePerl. It is used to install applications and hotfixes on Windows servers. I am trying to modify this to work with the 64bit version of Windows 2003. The problem is that due to the registry re-direction that 64it uses to maintain 32bit compatibility, my script is not reading the registry keys properly.
> Here is a sample of my script. the CHKPATCH subroutine is used to test for the existence of a patch
> e.g to determine if KB896424 is installed I simply call CHKPATCH("KB896424").
> On 64bit, this utility does not read the registry key listed below because its running in 32 bit mode
> even though I can see the key when I run Regedit from the server.
>
> use Win32::TieRegistry(Delimiter=>"/");
> .......
> sub CHKPATCH
> {
>     my $hotfix;
>     if($hotfix =$Registry->{"LMachine/SOFTWARE/Microsoft/Windows NT/CurrentVersion/HotFix/$_[0]"})
>     {
>         return 1;
>     }
>     else
>     {
>       return 0;
>     }
>    
> }
>
> Sorry for Rambling on and on but if anyone has any ideas I would be most appreciative


**********
In my search for a solution to the problem I was having accessing 64bit registry view on a 64bit Windows OS
I reviewed Microsoft's information on accessing an alternate registry view (http://msdn.microsoft.com/library/default.asp?url="">
Microsoft's 64bit registry access now defines the following constants

KEY_WOW64_64KEY 0x0100 Access a 64-bit key from either a 32-bit or 64-bit application.
KEY_WOW64_32KEY 0x0200 Access a 32-bit key from either a 32-bit or 64-bit application.

I also reviewed the documentation of Tye McQueen's Win32::TieRegistry module and
added the following lines of code to the TieRegistry.pm file  to use the above constants

sub KEY_WOW64_64KEY () { 0x0100}
sub KEY_WOW64_32KEY () { 0x0200}

Finally I changed the following code in TieRegistry.pm to include 64bit registry access by Oring (|) the above constants with KEY_READ

=======Original=================
# Basic master Registry object:
$RegObj= {};
@$RegObj{qw( HANDLE MACHINE PATH DELIM OS_DELIM ACCESS FLAGS ROOTS )}= (
    "NONE", "", [], "\\", "\\",
    KEY_READ|KEY_WRITE, $Flag_HexDWord|$Flag_FixNulls, "${PACK}::_Roots" );
=================================

=======Updated===========
# Basic master Registry object:
$RegObj= {};
@$RegObj{qw( HANDLE MACHINE PATH DELIM OS_DELIM ACCESS FLAGS ROOTS )}= (
    "NONE", "", [], "\\", "\\",
    KEY_READ|KEY_WRITE|KEY_WOW64_64KEY|KEY_WOW64_32KEY, $Flag_HexDWord|$Flag_FixNulls, "${PACK}::_Roots" );

I know this probably isnt the best way to make these changes and but it did the trick
I am able to use this script on both Win32 and x64 windows systems to access the registry.
I am copying Tye on this email. I hope an updated version of the module will be released soon

Thanks everyone for the many replies on this problem

Tony B. Okusanya
Distributed Technology Group
"Live Life By Design And Not From Crisis to Crisis"

------------------------------------------------------------------------------
Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation.
==============================================================================

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to