# parameters use Win32::Registry; if ($Win32::Registry::VERSION < 0.08 and !defined($Win32::Registry2::VERSION)) { die "Please update your Win32::Registry to 0.08 or newer or install the patch from http://jenda.krynicky.cz/#Win32::Registry2\n\n"; } my $ServiceKey; { my $paramkey; sub ReadParam { my ( $param, $default) = @_; $ServiceKey = $HKLM->Open('SYSTEM\CurrentControlSet\Services\\'.$svcid) unless $ServiceKey; return $default unless $ServiceKey; $paramkey = $ServiceKey->Create('Parameters') unless $paramkey; my $value = $paramkey->GetValue($param); $value = $default unless defined $value; return $value; } sub SaveParam { my ( $param, $value) = @_; $ServiceKey = $HKLM->Open('SYSTEM\CurrentControlSet\Services\\'.$svcid) unless $ServiceKey; return unless $ServiceKey; # do not save anything if the service is not installed $paramkey = $ServiceKey->Create('Parameters') unless $paramkey; die "Can't open/create the Parameters subkey in the service settings!\n" unless $paramkey; # do not save anything if the service is not installed if (!defined $value) { $paramkey->DeleteValue($param); } elsif ($value =~ /^\d+$/) { $paramkey->SetValues($param, REG_DWORD, $value); } else{ $value =~ s/\r?\n/\r\n/g; $paramkey->SetValues($param, REG_SZ, $value); } } }