Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Win32::TieRegistry delimiters

Status
Not open for further replies.

svar

Programmer
Aug 12, 2001
349
0
0
GR
I am having trouble with delimiters in this module:
use strict;
require('dumpvar.pl');
use Win32::TieRegistry ( TiedHash => '%RegHash' );
my $computer; my $Registry= \%RegHash;
my @keys= keys( %{ $Registry->{"HKEY_LOCAL_MACHINE"} } );
print "keys =@keys \n";
#writes:keys =HARDWARE\ SAM\ SECURITY\ SOFTWARE\ SYSTEM\
#die;
#my $tipdir0= $Registry->{"HKEY_LOCAL_MACHINE"};#works
my $tipdir0= $Registry->{"HKEY_LOCAL_MACHINE\\SYSTEM\\"};
#gives undef
&main::dumpValue($tipdir0);

Any (working) example for using delimiters?
 
what do you mean by delimiters? linebreaks?
Code:
print "keys =". join ("\n", @keys);

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
No, I mean the / or \\, e.g. what separates HKEY_LOCAL_MACHINE and SYSTEM below
HKEY_LOCAL_MACHINE\\SYSTEM\\
 
I want to access HKEY_LOCAL_MACHINE/System/ControlSet001/Control/Class(I can do that graphically)


use strict;
use warnings;
use Win32::TieRegistry;
require('dumpvar.pl');

sub rep;
my $verb = 1;

$Registry->Delimiter('/');
my $key = "HKEY_LOCAL_MACHINE";
#my $key = "HKEY_LOCAL_MACHINE/System/ControlSet001/Control/Class";
#&main::dumpValue($Registry);
print "dump $key\n";&main::dumpValue($Registry->{$key});
# this prints:
#dump HKEY_LOCAL_MACHINE
#'HARDWARE/' => undef
#'SAM/' => undef
#'SECURITY/' => undef
#'SOFTWARE/' => Win32::TieRegistry=HASH(0x1ace558)
#......
#'SYSTEM/' => undef
my @skeys = $Registry->{$key}->Win32::TieRegistry::SubKeyNames or
die "subkeys not found in key: $! ($^E)";
rep "subkeys: @skeys", $verb;

### This prints: subkeys: HARDWARE SAM SECURITY SOFTWARE SYSTEM

Why is software seen and the others not? All of them are accecible graphically
 
Could be a permissions issue, have you tried creating a key in the software branch?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Not sure how to check permissions(I really don;t want to mess with the system by creating keys), but it sure looks that way:
Here is a script:

use strict;
use warnings;
use Win32::TieRegistry;
require('dumpvar.pl');
&rep();

sub rep;
my $verb = 1;

#$Registry->Delimiter('/');
#first, the example from cpan:
my @allkeys=keys( %{ $Registry->{"HKEY_CLASSES_ROOT\\batfile\\"}}) ;
print "allkeys=@allkeys\n";
#Works ok, Prints:allkeys=DefaultIcon\ shell\ shellex\ \ \EditFlags
my @ballkeys=keys( %{ $Registry->{"HKEY_LOCAL_MACHINE\\System\\"}}) ;

print "ballkeys=@ballkeys\n";
#Apparently does not work, I get: ballkeys=
my @ballkeys=keys( %{ $Registry->{"HKEY_LOCAL_MACHINE\\"}}) ; #prints
print "ballkeys=@ballkeys\n";
#works, I get:ballkeys=HARDWARE\ SAM\ SECURITY\ SOFTWARE\ SYSTEM\
#so ok, maybe it's case sensitive. Let's try:
my @ballkeys=keys( %{ $Registry->{"HKEY_LOCAL_MACHINE\\SYSTEM\\"}}) ; print "ballkeys=@ballkeys\n";
#I get ballkeys=
#Now let's try another HKEY_LOCAL_MACHINE subkey:
my @ballkeys=keys( %{ $Registry->{"HKEY_LOCAL_MACHINE\\SOFTWARE\\"}}) ;
print "ballkeys=@ballkeys\n";
#I get: ballkeys=ActiveState\ Adobe\ Analog Devices\ C07ft5Y\ Classes\ Clients\ Crystal Decisions\ Dell Computer Corporation\ Deloitte Touche Tohmatsu\ DTTAS2Folio\ FolioViewsENU\ Gemplus\ Hewlett-Packard\ InstalledOptions\ InstallShield\ Intel\ lameme\ LEXMARK\ LizardTech\ Macromedia\ Microsoft\ ODBC\ Oracle\ Perl\ Policies\ Program Groups\ Reflection\ Schlumberger\ Secure\ Sensaura\ Staccato\ TrendMicro\ Windows 3.1 Migration Status\

die;

}
 
Forgot to mention: I CAN access system with regedit,
so if it is a permission problem, I am very unsure why this is so.
 
Ok, this worked-the problem wqs that TieRegistry opens read and write by default -and it fails if you do not have write, so opening as read only works.

Now, my next problem is understand where(some) things are
in the Registry.
The pieces of information(which you can get, I am told , with VBscript) that I have not (yet?) been able to find are:

-RAM
-(Free)? Disk Space
-Use name
-Computer name
-patches+hotfixes
-recent changes
-installed SW(other than LMachine/Software)
Any ideas or pointers?

Could it be that these are not in the registry and VB script
picks them up by other means?
 
maybe security patches are in Lmachine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\KBkeys?
 
that's one for the windows forum methinks ...

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top