source: trunk/cic-hcap/bin/windows/perl/site/lib/Win32/Service.pm@ 11852

Last change on this file since 11852 was 11852, checked in by mdewsnip, 18 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1package Win32::Service;
2
3#
4# Service.pm
5# Written by [email protected]
6#
7# subsequently hacked by Gurusamy Sarathy <[email protected]>
8#
9
10$VERSION = '0.05';
11
12require Exporter;
13require DynaLoader;
14
15die "The Win32::Service module works only on Windows NT" if(!Win32::IsWinNT());
16
17@ISA= qw( Exporter DynaLoader );
18@EXPORT_OK =
19 qw(
20 StartService
21 StopService
22 GetStatus
23 PauseService
24 ResumeService
25 GetServices
26 );
27
28=head1 NAME
29
30Win32::Service - manage system services in perl
31
32=head1 SYNOPSIS
33
34 use Win32::Service;
35
36=head1 DESCRIPTION
37
38This module offers control over the administration of system services.
39
40=head1 FUNCTIONS
41
42=head2 NOTE:
43
44All of the functions return false if they fail, unless otherwise noted.
45If hostName is an empty string, the local machine is assumed.
46
47=over 10
48
49=item StartService(hostName, serviceName)
50
51Start the service serviceName on machine hostName.
52
53=item StopService(hostName, serviceName)
54
55Stop the service serviceName on the machine hostName.
56
57=item GetStatus(hostName, serviceName, status)
58
59Get the status of a service. The third argument must be a hash
60reference that will be populated with entries corresponding
61to the SERVICE_STATUS structure of the Win32 API. See the
62Win32 Platform SDK documentation for details of this structure.
63
64=item PauseService(hostName, serviceName)
65
66=item ResumeService(hostName, serviceName)
67
68=item GetServices(hostName, hashref)
69
70Enumerates both active and inactive Win32 services at the specified host.
71The hashref is populated with the descriptive service names as keys
72and the short names as the values.
73
74=back
75
76=cut
77
78sub AUTOLOAD
79{
80 my($constname);
81 ($constname = $AUTOLOAD) =~ s/.*:://;
82 #reset $! to zero to reset any current errors.
83 local $! = 0;
84 my $val = constant($constname);
85 if ($! != 0) {
86 if($! =~ /Invalid/) {
87 $AutoLoader::AUTOLOAD = $AUTOLOAD;
88 goto &AutoLoader::AUTOLOAD;
89 }
90 else {
91 ($pack,$file,$line) = caller;
92 die "Your vendor has not defined Win32::Service macro $constname, used in $file at line $line.";
93 }
94 }
95 eval "sub $AUTOLOAD { $val }";
96 goto &$AUTOLOAD;
97}
98
99bootstrap Win32::Service;
100
1011;
102__END__
Note: See TracBrowser for help on using the repository browser.