programming-examples/perl/Win32/Lists services(daemon) on a given system.pl

27 lines
467 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl -w
use Win32::Service;
$host = '';
$status = Win32::Service::GetServices($host, \%services);
if ($status) {
print_hash( \%services );
} else {
print_error();
}
sub print_hash {
my($hash_ref) = $_[0];
@keys = keys( %$hash_ref );
@sorted = sort( @keys );
foreach $key (@sorted) {
print "$key $$hash_ref{$key}\n";
}
}
sub print_error {
print Win32::FormatMessage( Win32::GetLastError() );
}