home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / Win32 / Process.pm < prev    next >
Encoding:
Perl POD Document  |  1997-08-10  |  3.1 KB  |  141 lines

  1. package Win32::Process;
  2.  
  3. use Win32::IPC;
  4. require Exporter;
  5. require DynaLoader;
  6. require AutoLoader;
  7. @ISA = qw(Exporter DynaLoader Win32::IPC);
  8.  
  9. $VERSION = '0.01';
  10.  
  11. =head1 NAME
  12.  
  13. Win32::Process - Create and manipulate processes.
  14.  
  15. =head1 SYNOPSIS
  16.     use Win32::Process;
  17.     use Win32;        
  18.     
  19.     sub ErrorReport{
  20.         print Win32::FormatMessage( Win32::GetLastError() );
  21.     }
  22.     
  23.     Win32::Process::Create($ProcessObj,
  24.                 "D:\\winnt35\\system32\\notepad.exe",
  25.                 "notepad temp.txt",
  26.                 0,
  27.                 NORMAL_PRIORITY_CLASS,
  28.                 ".")|| die ErrorReport();
  29.     
  30.     $ProcessObj->Suspend();
  31.     $ProcessObj->Resume();
  32.     $ProcessObj->Wait(INFINITE);
  33.  
  34. =head1  DESCRIPTION
  35.  
  36. This module allows for control of processes in Perl.
  37.  
  38. =head1 METHODS
  39.  
  40. =over 8
  41.  
  42. =item Win32::Process::Create($obj,$appname,$cmdline,$iflags,$cflags,$curdir)
  43.  
  44. Creates a new process.
  45.  
  46.     Args:
  47.  
  48.     $obj        container for process object
  49.     $appname    full path name of executable module
  50.     $cmdline    command line args
  51.     $iflags        flag: inherit calling processes handles or not
  52.     $cflags        flags for creation (see exported vars below)
  53.     $curdir        working dir of new process
  54.  
  55. =item $ProcessObj->Suspend()
  56.  
  57. Suspend the process associated with the $ProcessObj.
  58.  
  59. =item $ProcessObj->Resume()
  60.  
  61. Resume a suspended process.
  62.  
  63. =item $ProcessObj->Kill( $ExitCode )
  64.  
  65. Kill the associated process, have it die with exit code $ExitCode.
  66.  
  67. =item $ProcessObj->GetPriorityClass($class)
  68.  
  69. Get the priority class of the process.
  70.  
  71. =item $ProcessObj->SetPriorityClass( $class )
  72.  
  73. Set the priority class of the process (see exported values below for
  74. options).
  75.  
  76. =item $ProcessObj->GetExitCode( $ExitCode )
  77.  
  78. Retrieve the exitcode of the process.
  79.  
  80. =item $ProcessObj->Wait($Timeout)
  81.  
  82. Wait for the process to die. forever = INFINITE
  83.  
  84. =back
  85.  
  86. =cut
  87.  
  88. # Items to export into callers namespace by default. Note: do not export
  89. # names by default without a very good reason. Use EXPORT_OK instead.
  90. # Do not simply export all your public functions/methods/constants.
  91. @EXPORT = qw(
  92.     CREATE_DEFAULT_ERROR_MODE
  93.     CREATE_NEW_CONSOLE
  94.     CREATE_NEW_PROCESS_GROUP
  95.     CREATE_NO_WINDOW
  96.     CREATE_SEPARATE_WOW_VDM
  97.     CREATE_SUSPENDED
  98.     CREATE_UNICODE_ENVIRONMENT
  99.     DEBUG_ONLY_THIS_PROCESS
  100.     DEBUG_PROCESS
  101.     DETACHED_PROCESS
  102.     HIGH_PRIORITY_CLASS
  103.     IDLE_PRIORITY_CLASS
  104.     INFINITE
  105.     NORMAL_PRIORITY_CLASS
  106.     REALTIME_PRIORITY_CLASS
  107.     THREAD_PRIORITY_ABOVE_NORMAL
  108.     THREAD_PRIORITY_BELOW_NORMAL
  109.     THREAD_PRIORITY_ERROR_RETURN
  110.     THREAD_PRIORITY_HIGHEST
  111.     THREAD_PRIORITY_IDLE
  112.     THREAD_PRIORITY_LOWEST
  113.     THREAD_PRIORITY_NORMAL
  114.     THREAD_PRIORITY_TIME_CRITICAL
  115. );
  116.  
  117. sub AUTOLOAD {
  118.     my($constname);
  119.     ($constname = $AUTOLOAD) =~ s/.*:://;
  120.     #reset $! to zero to reset any current errors.
  121.     $!=0;
  122.     my $val = constant($constname, @_ ? $_[0] : 0);
  123.     if ($! != 0) {
  124.     if ($! =~ /Invalid/) {
  125.         $AutoLoader::AUTOLOAD = $AUTOLOAD;
  126.         goto &AutoLoader::AUTOLOAD;
  127.     }
  128.     else {
  129.         ($pack,$file,$line) = caller;
  130.         die "Your vendor has not defined Win32::Process macro $constname, used at $file line $line.";
  131.     }
  132.     }
  133.     eval "sub $AUTOLOAD { $val }";
  134.     goto &$AUTOLOAD;
  135. }
  136.  
  137. bootstrap Win32::Process;
  138.  
  139. 1;
  140. __END__
  141.