Is there a value called DisplayName in every key under Uninstall? My
guess is that you will find on the computers where this fails that there
is a key that is "incomplete", either from a partial uninstall or a
badly installed program.
By the way, I don't think you actually need to call the GetValue
function. Win32::TieRegistry will handle this for you. All you need to
do is something like this:
#####################################
use strict;
use warnings;
use Win32::TieRegistry (Delimiter => '/');
my $swKey =
$Registry->{"LMachine/Software/Microsoft/Windows/CurrentVersion/Uninstal
l/"};
my @ls= keys( %{$swKey} );
my $p ='0';
my %list_soft = ();
foreach my $entry (@ls ){
my $Key =
$Registry->{"LMachine/Software/Microsoft/Windows/CurrentVersion/Uninstal
l/$entry"};
my $valueString = $Key->{DisplayName};
if(defined $valueString){
$valueString =~ s/ //g;
$list_soft{$valueString} = $p;
}
}
######################################
Also, you are forgetting to 'use strict' and 'use warnings'. You should
always use strict and warnings.
-----Original Message-----
From: OXx [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 17, 2006 4:13 PM
To: [email protected]
Subject: Win32::TieRegistry problem
Hello I have a problem with this module.
My script does not work with all pcs .
In fact when I execute it on my computer I have no problem but in an
other
one I have this error:
*Can't call method "GetValue" on an undefined value*
An extract of my script:
$Registry->Delimiter("/");
$swKey=
$Registry->{"LMachine/Software/Microsoft/Windows/CurrentVersion/Uninstal
l/"};
@ls= keys( %{$swKey} );
$p ='0';
%list_soft = ();
foreach $entry (@ls )
{
$Key=
$Registry->{"LMachine/Software/Microsoft/Windows/CurrentVersion/Uninstal
l/$entry"};
*$valueString= $Key->GetValue("DisplayName");*
$valueString=~s/ //g;
$list_soft{$valueString} = $p;
}
Thanks for your help
Oxx
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>