PERL Win32 Quick Reference
PERL Win32 Quick Reference
GetServices(hostName, hashref)
Enumerates both active and inactive Win32 services at the specified host. The ($hz, $bits, $channels) = Win32::Sound::Format(filename) $ProcessObj->SetPriorityClass( $class )
hashref is populated with the descriptive service names as keys and the short Returns information about the specified WAV file format; the array contains. Set the priority class of the process (see exported values below for options).
names as the values.
@devices = Win32::Sound::Devices();
$ProcessObj->GetProcessAffinitymask( $processAffinityMask,
Returns all the available sound devices.
$systemAffinitymask)
Win32::Sound Get the process affinity mask. This is a bitvector in which each bit represents
the processors that a process is allowed to run on.
use Win32::Sound; %Info = Win32::Sound::DeviceInfo(DEVICE)
Returns an associative array of information about the sound device named
Win32::Sound::Volume('100%');
DEVICE.
Win32::Sound::Play("c:/winnt/media/notify.wav"); $ProcessObj->SetProcessAffinitymask( $processAffinityMask )
Win32::Sound::Stop(); Set the process affinity mask. Only available on Windows NT.
Win32::Process
$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"}=
$ProcessObj->Wait($timeout) [ "D:\x00\\\\SwServer\\SwShare\\Windows\0\0", "REG_MULTI_SZ" ];
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.
$ProcessObj->GetProcessID() $userKey->{"Explorer/Tips//DisplayInitialTipWindow"}=
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
use Win32::TieRegistry( Delimiter=>"#", ArrayValues=>0 ); Adding keys
$pound= $Registry->Delimiter("/"); $swKey->{"FooCorp/"}= {
$diskKey= $Registry->{"LMachine/System/Disk/"} "FooWriter/" => {
or die "Can't read LMachine/System/Disk key: $^E\n"; "/Version" => "4.032",
$data= $key->{"/Information"} "Startup/" => {
or die "Can't read LMachine/System/Disk//Information value: $^E\n"; "/Title" => "Foo Writer Deluxe ][",
$remoteKey= $Registry->{"//ServerA/LMachine/System/"} "/WindowSize" => [ pack("LL",$wid,$ht), "REG_BINARY" ],
or die "Can't read //ServerA/LMachine/System/ key: $^E\n"; "/TaskBarIcon" => [ "0x0001", "REG_DWORD" ],
$remoteData= $remoteKey->{"Disk//Information"} },
or die "Can't read ServerA's System/Disk//Information value: $^E\n"; "Compatibility/" => {
foreach $entry ( keys(%$diskKey) ) { "/AutoConvert" => "Always",
... "/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} );
Opening keys @subKeys= grep( m#^/#, keys( %{$swKey->{"Classes/batfile/"}} ) );
use Win32::TieRegistry ( Delimiter=>"/", ArrayValues=>1 ); # @subKeys= ( "/", "/EditFlags" );
$Registry->Delimiter("/"); # Set delimiter to "/". @valueNames= grep( ! m#^/#, keys( %{$swKey->{"Classes/batfile/"}} )
$swKey= $Registry->{"LMachine/Software/"}; );
$winKey= $swKey->{"Microsoft/Windows/CurrentVersion/"}; # @valueNames= ( "DefaultIcon/", "shell/", "shellex/" );
$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/"};
Reading values # $oldValues will be reference to hash containing deleted keys values.
$progDir= $winKey->{"/ProgramFilesDir"}; # "C:\\Program Files"
$tip21= $winKey->{"Explorer/Tips//21"}; # Text of tip #21.
$winKey->ArrayValues(1); Closing keys
( $devPath, $type )= $winKey->{"/DevicePath"}; undef $swKey; # Explicit way to close a key.
# $devPath eq "%SystemRoot%\\inf" $winKey= "Anything else"; # Implicitly closes a key.
# $type eq "REG_EXPAND_SZ" [if you have SetDualVar.pm installed] exit 0; # Implicitly closes all keys.
# $type == REG_EXPAND_SZ() [if did C<use Win32::TieRegistry
qw(:REG_)>]