home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _9db4e7b016587af20cddde2eb61ee594 < prev    next >
Encoding:
Text File  |  2004-06-01  |  4.8 KB  |  198 lines

  1. package Win32::Process;
  2.  
  3. require Exporter;
  4. require DynaLoader;
  5. @ISA = qw(Exporter DynaLoader);
  6.  
  7. $VERSION = '0.09';
  8.  
  9. # Items to export into callers namespace by default. Note: do not export
  10. # names by default without a very good reason. Use EXPORT_OK instead.
  11. # Do not simply export all your public functions/methods/constants.
  12. @EXPORT = qw(
  13.     CREATE_DEFAULT_ERROR_MODE
  14.     CREATE_NEW_CONSOLE
  15.     CREATE_NEW_PROCESS_GROUP
  16.     CREATE_NO_WINDOW
  17.     CREATE_SEPARATE_WOW_VDM
  18.     CREATE_SUSPENDED
  19.     CREATE_UNICODE_ENVIRONMENT
  20.     DEBUG_ONLY_THIS_PROCESS
  21.     DEBUG_PROCESS
  22.     DETACHED_PROCESS
  23.     HIGH_PRIORITY_CLASS
  24.     IDLE_PRIORITY_CLASS
  25.     INFINITE
  26.     NORMAL_PRIORITY_CLASS
  27.     REALTIME_PRIORITY_CLASS
  28.     THREAD_PRIORITY_ABOVE_NORMAL
  29.     THREAD_PRIORITY_BELOW_NORMAL
  30.     THREAD_PRIORITY_ERROR_RETURN
  31.     THREAD_PRIORITY_HIGHEST
  32.     THREAD_PRIORITY_IDLE
  33.     THREAD_PRIORITY_LOWEST
  34.     THREAD_PRIORITY_NORMAL
  35.     THREAD_PRIORITY_TIME_CRITICAL
  36. );
  37.  
  38. sub AUTOLOAD {
  39.     # This AUTOLOAD is used to 'autoload' constants from the constant()
  40.     # XS function.
  41.     my($constname);
  42.     ($constname = $AUTOLOAD) =~ s/.*:://;
  43.     local $! = 0;
  44.     my $val = constant($constname);
  45.     if ($! != 0) {
  46.         my ($pack,$file,$line) = caller;
  47.         die "Your vendor has not defined Win32::Process macro $constname, used at $file line $line.";
  48.     }
  49.     eval "sub $AUTOLOAD { $val }";
  50.     goto &$AUTOLOAD;
  51. } # end AUTOLOAD
  52.  
  53. bootstrap Win32::Process;
  54.  
  55. 1;
  56. __END__
  57.  
  58. =head1 NAME
  59.  
  60. Win32::Process - Create and manipulate processes.
  61.  
  62. =head1 SYNOPSIS
  63.  
  64.     use Win32::Process;
  65.     use Win32;
  66.  
  67.     sub ErrorReport{
  68.     print Win32::FormatMessage( Win32::GetLastError() );
  69.     }
  70.  
  71.     Win32::Process::Create($ProcessObj,
  72.                 "C:\\winnt\\system32\\notepad.exe",
  73.                 "notepad temp.txt",
  74.                 0,
  75.                 NORMAL_PRIORITY_CLASS,
  76.                 ".")|| die ErrorReport();
  77.  
  78.     $ProcessObj->Suspend();
  79.     $ProcessObj->Resume();
  80.     $ProcessObj->Wait(INFINITE);
  81.  
  82. =head1  DESCRIPTION
  83.  
  84. This module provides access to the process control functions in the
  85. Win32 API.
  86.  
  87. =head1 METHODS
  88.  
  89. =over 8
  90.  
  91. =item Win32::Process::Create($obj,$appname,$cmdline,$iflags,$cflags,$curdir)
  92.  
  93. Creates a new process.
  94.  
  95.     Args:
  96.  
  97.     $obj        container for process object
  98.     $appname    full path name of executable module
  99.     $cmdline    command line args
  100.     $iflags        flag: inherit calling processes handles or not
  101.     $cflags        flags for creation (see exported vars below)
  102.     $curdir        working dir of new process
  103.  
  104. Returns non-zero on success, 0 on failure.
  105.  
  106. =item Win32::Process::Open($obj,$pid,$iflags)
  107.  
  108. Creates a handle Perl can use to an existing process as identified by $pid.
  109. The $iflags is the inherit flag that is passed to OpenProcess.  Currently
  110. Win32::Process objects created using Win32::Process::Open cannot Suspend
  111. or Resume the process.  All other calls should work.
  112.  
  113. Win32::Process::Open returns non-zero on success, 0 on failure.
  114.  
  115. =item Win32::Process::KillProcess($pid, $exitcode)
  116.  
  117. Terminates any process identified by $pid.  $exitcode will be set to
  118. the exit code of the process.
  119.  
  120. =item $ProcessObj->Suspend()
  121.  
  122. Suspend the process associated with the $ProcessObj.
  123.  
  124. =item $ProcessObj->Resume()
  125.  
  126. Resume a suspended process.
  127.  
  128. =item $ProcessObj->Kill($exitcode)
  129.  
  130. Kill the associated process, have it terminate with exit code $ExitCode.
  131.  
  132. =item $ProcessObj->GetPriorityClass($class)
  133.  
  134. Get the priority class of the process.
  135.  
  136. =item $ProcessObj->SetPriorityClass($class)
  137.  
  138. Set the priority class of the process (see exported values below for
  139. options).
  140.  
  141. =item $ProcessObj->GetProcessAffinityMask($processAffinityMask, $systemAffinityMask)
  142.  
  143. Get the process affinity mask.  This is a bitvector in which each bit
  144. represents the processors that a process is allowed to run on.
  145.  
  146. =item $ProcessObj->SetProcessAffinityMask($processAffinityMask)
  147.  
  148. Set the process affinity mask.  Only available on Windows NT.
  149.  
  150. =item $ProcessObj->GetExitCode($exitcode)
  151.  
  152. Retrieve the exitcode of the process.
  153.  
  154. =item $ProcessObj->Wait($timeout)
  155.  
  156. Wait for the process to die.  $timeout should be specified in milliseconds.
  157. To wait forever, specify the constant C<INFINITE>.
  158.  
  159. =item $ProcessObj->GetProcessID()
  160.  
  161. Returns the Process ID.
  162.  
  163. =back
  164.  
  165. =head1 EXPORTS
  166.  
  167. The following constants are exported by default.
  168.  
  169.     CREATE_DEFAULT_ERROR_MODE
  170.     CREATE_NEW_CONSOLE
  171.     CREATE_NEW_PROCESS_GROUP
  172.     CREATE_NO_WINDOW
  173.     CREATE_SEPARATE_WOW_VDM
  174.     CREATE_SUSPENDED
  175.     CREATE_UNICODE_ENVIRONMENT
  176.     DEBUG_ONLY_THIS_PROCESS
  177.     DEBUG_PROCESS
  178.     DETACHED_PROCESS
  179.     HIGH_PRIORITY_CLASS
  180.     IDLE_PRIORITY_CLASS
  181.     INFINITE
  182.     NORMAL_PRIORITY_CLASS
  183.     REALTIME_PRIORITY_CLASS
  184.     THREAD_PRIORITY_ABOVE_NORMAL
  185.     THREAD_PRIORITY_BELOW_NORMAL
  186.     THREAD_PRIORITY_ERROR_RETURN
  187.     THREAD_PRIORITY_HIGHEST
  188.     THREAD_PRIORITY_IDLE
  189.     THREAD_PRIORITY_LOWEST
  190.     THREAD_PRIORITY_NORMAL
  191.     THREAD_PRIORITY_TIME_CRITICAL
  192.  
  193. =cut
  194.  
  195. # Local Variables:
  196. # tmtrack-file-task: "Win32::Process"
  197. # End:
  198.