Source code of Windows XP (NT5)
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.

145 lines
3.3 KiB

  1. package Win32::Process;
  2. require Exporter;
  3. require DynaLoader;
  4. @ISA = qw(Exporter DynaLoader);
  5. $VERSION = '0.05';
  6. # Items to export into callers namespace by default. Note: do not export
  7. # names by default without a very good reason. Use EXPORT_OK instead.
  8. # Do not simply export all your public functions/methods/constants.
  9. @EXPORT = qw(
  10. CREATE_DEFAULT_ERROR_MODE
  11. CREATE_NEW_CONSOLE
  12. CREATE_NEW_PROCESS_GROUP
  13. CREATE_NO_WINDOW
  14. CREATE_SEPARATE_WOW_VDM
  15. CREATE_SUSPENDED
  16. CREATE_UNICODE_ENVIRONMENT
  17. DEBUG_ONLY_THIS_PROCESS
  18. DEBUG_PROCESS
  19. DETACHED_PROCESS
  20. HIGH_PRIORITY_CLASS
  21. IDLE_PRIORITY_CLASS
  22. INFINITE
  23. NORMAL_PRIORITY_CLASS
  24. REALTIME_PRIORITY_CLASS
  25. THREAD_PRIORITY_ABOVE_NORMAL
  26. THREAD_PRIORITY_BELOW_NORMAL
  27. THREAD_PRIORITY_ERROR_RETURN
  28. THREAD_PRIORITY_HIGHEST
  29. THREAD_PRIORITY_IDLE
  30. THREAD_PRIORITY_LOWEST
  31. THREAD_PRIORITY_NORMAL
  32. THREAD_PRIORITY_TIME_CRITICAL
  33. );
  34. sub AUTOLOAD {
  35. # This AUTOLOAD is used to 'autoload' constants from the constant()
  36. # XS function.
  37. my($constname);
  38. ($constname = $AUTOLOAD) =~ s/.*:://;
  39. my $val = constant($constname);
  40. if ($! != 0) {
  41. my ($pack,$file,$line) = caller;
  42. die "Your vendor has not defined Win32::Process macro $constname, used at $file line $line.";
  43. }
  44. eval "sub $AUTOLOAD { $val }";
  45. goto &$AUTOLOAD;
  46. } # end AUTOLOAD
  47. bootstrap Win32::Process;
  48. 1;
  49. __END__
  50. =head1 NAME
  51. Win32::Process - Create and manipulate processes.
  52. =head1 SYNOPSIS
  53. use Win32::Process;
  54. use Win32;
  55. sub ErrorReport{
  56. print Win32::FormatMessage( Win32::GetLastError() );
  57. }
  58. Win32::Process::Create($ProcessObj,
  59. "D:\\winnt35\\system32\\notepad.exe",
  60. "notepad temp.txt",
  61. 0,
  62. NORMAL_PRIORITY_CLASS,
  63. ".")|| die ErrorReport();
  64. $ProcessObj->Suspend();
  65. $ProcessObj->Resume();
  66. $ProcessObj->Wait(INFINITE);
  67. =head1 DESCRIPTION
  68. This module allows for control of processes in Perl.
  69. =head1 METHODS
  70. =over 8
  71. =item Win32::Process::Create($obj,$appname,$cmdline,$iflags,$cflags,$curdir)
  72. Creates a new process.
  73. Args:
  74. $obj container for process object
  75. $appname full path name of executable module
  76. $cmdline command line args
  77. $iflags flag: inherit calling processes handles or not
  78. $cflags flags for creation (see exported vars below)
  79. $curdir working dir of new process
  80. =item $ProcessObj->Suspend()
  81. Suspend the process associated with the $ProcessObj.
  82. =item $ProcessObj->Resume()
  83. Resume a suspended process.
  84. =item $ProcessObj->Kill( $ExitCode )
  85. Kill the associated process, have it die with exit code $ExitCode.
  86. =item $ProcessObj->GetPriorityClass($class)
  87. Get the priority class of the process.
  88. =item $ProcessObj->SetPriorityClass( $class )
  89. Set the priority class of the process (see exported values below for
  90. options).
  91. =item $ProcessObj->GetProcessAffinitymask( $processAffinityMask, $systemAffinitymask)
  92. Get the process affinity mask. This is a bitvector in which each bit
  93. represents the processors that a process is allowed to run on.
  94. =item $ProcessObj->SetProcessAffinitymask( $processAffinityMask )
  95. Set the process affinity mask. Only available on Windows NT.
  96. =item $ProcessObj->GetExitCode( $ExitCode )
  97. Retrieve the exitcode of the process.
  98. =item $ProcessObj->Wait($Timeout)
  99. Wait for the process to die. forever = INFINITE
  100. =back
  101. =cut
  102. # Local Variables:
  103. # tmtrack-file-task: "Win32::Process"
  104. # End: