Perl Win32 Quick Reference Page 4

ADVERTISEMENT

$ProcessObj->GetExitCode( $exitcode )
Setting values
Retrieve the exitcode of the process.
$winKey->{"Setup//SourcePath"}= "\\\\SwServer\\SwShare\\Windows";
# Simple. Assumes data type of REG_SZ.
$winKey->{"Setup//Installation Sources"}=
[ "D:\x00\\\\SwServer\\SwShare\\Windows\0\0", "REG_MULTI_SZ" ];
$ProcessObj->Wait($timeout)
Wait for the process to die. $timeout should be specified in milliseconds. To
# "\x00" and "\0" used to mark ends of each string and end of list.
wait forever, specify the constant INFINITE.
$winKey->{"Setup//Installation Sources"}=
[ ["D:","\\\\SwServer\\SwShare\\Windows"], "REG_MULTI_SZ" ];
# Alternate method that is easier to read.
$userKey->{"Explorer/Tips//DisplayInitialTipWindow"}=
$ProcessObj->GetProcessID()
Returns the Process ID.
[ pack("L",0), "REG_DWORD" ];
$userKey->{"Explorer/Tips//Next"}= [ pack("S",3), "REG_BINARY" ];
$userKey->{"Explorer/Tips//Show"}= [ pack("L",0), "REG_BINARY" ];
Win32::TieRegistry
Adding keys
use Win32::TieRegistry( Delimiter=>"#", ArrayValues=>0 );
$swKey->{"FooCorp/"}= {
$pound= $Registry->Delimiter("/");
"FooWriter/" => {
$diskKey= $Registry->{"LMachine/System/Disk/"}
"/Version" => "4.032",
or die "Can't read LMachine/System/Disk key: $^E\n";
"Startup/" => {
$data= $key->{"/Information"}
"/Title" => "Foo Writer Deluxe ][",
or die "Can't read LMachine/System/Disk//Information value: $^E\n";
"/WindowSize" => [ pack("LL",$wid,$ht), "REG_BINARY" ],
$remoteKey= $Registry->{"//ServerA/LMachine/System/"}
"/TaskBarIcon" => [ "0x0001", "REG_DWORD" ],
or die "Can't read //ServerA/LMachine/System/ key: $^E\n";
},
$remoteData= $remoteKey->{"Disk//Information"}
"Compatibility/" => {
or die "Can't read ServerA's System/Disk//Information value: $^E\n";
"/AutoConvert" => "Always",
foreach $entry ( keys(%$diskKey) ) {
"/Default Palette" => "Windows Colors",
...
},
}
},
foreach $subKey ( $diskKey->SubKeyNames ) {
"/License", => "0123-9C8EF1 -09-FC",
...
}
$diskKey->AllowSave( 1 );
Listing all subkeys and values
$diskKey->RegSaveKey( "C:/TEMP/DiskReg", [] );
@members= keys( %{$swKey} );
@subKeys= grep( m#^/#, keys( %{$swKey->{"Classes/batfile/"}} ) );
Opening keys
# @subKeys= ( "/", "/EditFlags" );
use Win32::TieRegistry ( Delimiter=>"/", ArrayValues=>1 );
@valueNames= grep( ! m#^/#, keys( %{$swKey->{"Classes/batfile/"}} )
$Registry->Delimiter("/");
# Set delimiter to "/".
);
$swKey= $Registry->{"LMachine/Software/"};
# @valueNames= ( "DefaultIcon/", "shell/", "shellex/" );
$winKey= $swKey->{"Microsoft/Windows/CurrentVersion/"};
$userKey= $Registry->
{"CUser/Software/Microsoft/Windows/CurrentVersion/"};
Deleting values or keys with no subkeys
$remoteKey= $Registry->{"//HostName/LMachine/"};
$oldValue= delete $userKey->{"Explorer/Tips//Next"};
$oldValues= delete $userKey->{"Explorer/Tips/"};
# $oldValues will be reference to hash containing deleted keys values.
Reading values
$progDir= $winKey->{"/ProgramFilesDir"}; # "C:\\Program Files"
$tip21= $winKey->{"Explorer/Tips//21"};
# Text of tip #21.
Closing keys
$winKey->ArrayValues(1);
undef $swKey;
# Explicit way to close a key.
( $devPath, $type )= $winKey->{"/DevicePath"};
$winKey= "Anything else"; # Implicitly closes a key.
# $devPath eq "%SystemRoot%\\inf"
exit 0;
# Implicitly closes all keys.
# $type eq "REG_EXPAND_SZ" [if you have SetDualVar.pm installed]
# $type == REG_EXPAND_SZ() [if did C<use Win32::TieRegistry
qw(:REG_)>]

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 4