Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.2 KiB

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