home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1997 / CT_SW_97.ISO / pc / software / entwickl / win95 / pw32i306.exe / lib / Win32 / process.pm < prev    next >
Text File  |  1996-11-25  |  3KB  |  136 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. =head1 NAME
  9.  
  10. Win32::Process - Create and manipulate processes.
  11.  
  12. =head1 SYNOPSIS
  13.     use Win32::Process;
  14.     use Win32;        
  15.     
  16.     sub ErrorReport{
  17.         print Win32::FormatMessage( Win32::GetLastError() );
  18.     }
  19.  
  20.         Win32::Process::Create($ProcessObj,
  21.                         "D:\\winnt35\\system32\\notepad.exe",
  22.                         "notepad temp.txt",
  23.                         0,
  24.                         NORMAL_PRIORITY_CLASS,
  25.                         ".")|| die ErrorReport();
  26.         
  27.         $ProcessObj->Suspend();
  28.         $ProcessObj->Resume();
  29.         $ProcessObj->Wait(INFINITE);
  30.  
  31.  
  32.  
  33.  
  34. =head1  DESCRIPTION
  35.  
  36. This module allows for control of processes in Perl.
  37.  
  38. =head1 METHODS
  39.  
  40.     Win32::Process::Create($ProcessObj,        #container for process object
  41.                         $AppName,               #full path name of executable module
  42.                         $CommLine,              #command line args
  43.                         $Inherit,               #flag: inherit calling processes handles or no.
  44.                         $CreateFlags,   #flags for creation, see exported var below.)
  45.                         $InitialDir )   #working dir of new process.
  46.  
  47.     $ProcessObj->Suspend();
  48.         Suspend the process associated with the $ProcessObj;
  49.  
  50.     $ProcessObj->Resume()
  51.         Resume a suspended process
  52.  
  53.     $ProcessObj->Kill( $ExitCode );
  54.         Kill the associated process, have it die with exit code 
  55.             $ExitCode
  56.  
  57.     $ProcessObj->GetPriorityClass($class)
  58.         Get the priority class of the process
  59.  
  60.     $ProcessObj->SetPriorityClass( $class )
  61.         Set the priority class of the process
  62.         ( See exported values below for options).
  63.  
  64.     $ProcessObj->GetExitCode( $ExitCode )
  65.         retrieve the exitcode of the process.
  66.  
  67.     $ProcessObj->Wait($Timeout)
  68.         wait for the process to die. forever = INFINITE
  69.  
  70.  
  71.  
  72.  
  73. =cut
  74.  
  75. # Items to export into callers namespace by default. Note: do not export
  76. # names by default without a very good reason. Use EXPORT_OK instead.
  77. # Do not simply export all your public functions/methods/constants.
  78. @EXPORT = qw(
  79.     CREATE_DEFAULT_ERROR_MODE
  80.     CREATE_NEW_CONSOLE
  81.     CREATE_NEW_PROCESS_GROUP
  82.     CREATE_NO_WINDOW
  83.     CREATE_SEPARATE_WOW_VDM
  84.     CREATE_SUSPENDED
  85.     CREATE_UNICODE_ENVIRONMENT
  86.     DEBUG_ONLY_THIS_PROCESS
  87.     DEBUG_PROCESS
  88.     DETACHED_PROCESS
  89.     HIGH_PRIORITY_CLASS
  90.     IDLE_PRIORITY_CLASS
  91.     INFINITE
  92.     NORMAL_PRIORITY_CLASS
  93.     REALTIME_PRIORITY_CLASS
  94.     THREAD_PRIORITY_ABOVE_NORMAL
  95.     THREAD_PRIORITY_BELOW_NORMAL
  96.     THREAD_PRIORITY_ERROR_RETURN
  97.     THREAD_PRIORITY_HIGHEST
  98.     THREAD_PRIORITY_IDLE
  99.     THREAD_PRIORITY_LOWEST
  100.     THREAD_PRIORITY_NORMAL
  101.     THREAD_PRIORITY_TIME_CRITICAL
  102. );
  103.  
  104. sub AUTOLOAD {
  105.     # This AUTOLOAD is used to 'autoload' constants from the constant()
  106.     # XS function.  If a constant is not found then control is passed
  107.     # to the AUTOLOAD in AutoLoader.
  108.  
  109.     my($constname);
  110.     ($constname = $AUTOLOAD) =~ s/.*:://;
  111.     #reset $! to zero to reset any current errors.
  112.     $!=0;
  113.     my $val = constant($constname, @_ ? $_[0] : 0);
  114.     if ($! != 0) {
  115.     if ($! =~ /Invalid/) {
  116.         $AutoLoader::AUTOLOAD = $AUTOLOAD;
  117.         goto &AutoLoader::AUTOLOAD;
  118.     }
  119.     else {
  120.         ($pack,$file,$line) = caller;
  121.         die "Your vendor has not defined Win32::Process macro $constname, used at $file line $line.";
  122.     }
  123.     }
  124.     eval "sub $AUTOLOAD { $val }";
  125.     goto &$AUTOLOAD;
  126. }
  127.  
  128. bootstrap Win32::Process;
  129.  
  130. # Preloaded methods go here.
  131.  
  132. # Autoload methods go after __END__, and are processed by the autosplit program.
  133.  
  134. 1;
  135. __END__
  136.