home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
tema
/
sybase
/
powerj
/
hpp.z
/
WPROCESS.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-18
|
8KB
|
254 lines
/********************************************************************
*
* Processes
*
* Two classes are available:
*
* WCurrentProcess -- Always refers to the current process.
*
* WProcess -- Refers to a specific process.
*
* If you want to do something related to the current process,
* use an object of type WCurrentProcess. Otherwise you need
* an object of class WProcess, which can only be had in the
* following manner:
*
* 1) Calling the Create method.
*
* 2) Assignment from another WProcess.
*
* 3) Assignment from a WCurrentProcess.
*
********************************************************************/
#ifndef _WPROCESS_HPP_INCLUDED
#define _WPROCESS_HPP_INCLUDED
#ifndef _WNO_PRAGMA_PUSH
#pragma pack(push,8);
#pragma enum int;
#endif
#ifndef _WDEF_HPP_INCLUDED
# include "wdef.hpp"
#endif
#ifndef _WOBJECT_HPP_INCLUDED
# include "wobject.hpp"
#endif
#ifndef _WSEMAPHORE_HPP_INCLUDED
# include "wsemaphr.hpp"
#endif
class WProcess;
class WThread;
class WProcessReference;
enum WProcessPriority {
ProcessPriorityIdle,
ProcessPriorityNormal,
ProcessPriorityHigh,
ProcessPriorityRealTime
};
#define WPROCESS_CREATE_DEFAULT_ERROR_MODE 0x04000000
#define WPROCESS_CREATE_NEW_CONSOLE 0x00000010
#define WPROCESS_CREATE_NEW_PROCESS_GROUP 0x00000200
#define WPROCESS_CREATE_SEPARATE_WOW_VDM 0x00000800
#define WPROCESS_CREATE_SHARED_WOW_VDM 0x00001000
#define WPROCESS_CREATE_SUSPENDED 0x00000004
#define WPROCESS_CREATE_UNICODE_ENVIRONMENT 0x00000400
#define WPROCESS_DEBUG_PROCESS 0x00000001
#define WPROCESS_DEBUG_ONLY_THIS_PROCESS 0x00000002
#define WPROCESS_DETACHED_PROCESS 0x00000008
#define WPROCESS_NORMAL_PRIORITY_CLASS 0x00000020
#define WPROCESS_IDLE_PRIORITY_CLASS 0x00000040
#define WPROCESS_HIGH_PRIORITY_CLASS 0x00000080
#define WPROCESS_REALTIME_PRIORITY_CLASS 0x00000100
enum WProcessHandle { NULLHPROCESS = 0, LASTHPROCESS = LAST_16TO32BIT };
//
// WProcessBase -- An abstract base class.
//
class WCMCLASS WProcessBase : public WObject {
WDeclareSubclass( WProcessBase, WObject );
private:
WProcessBase( const WProcessBase & );
WProcessBase& operator=( const WProcessBase & );
protected:
WProcessBase();
public:
~WProcessBase();
/***********************************************************
* Properties
***********************************************************/
// Active
//
// TRUE if the process is still running.
WBool GetActive() const;
// ExitCode
//
// Returns the exit code for the process. If the process
// is still active the result is undefined.
WDWord GetExitCode() const;
// Handle
virtual WProcessHandle GetHandle() const = 0;
// ID
virtual WDWord GetID() const = 0;
// Valid
//
// TRUE if the object represents (or represented)
// a valid process.
WBool GetValid() const;
/***********************************************************
* Methods
***********************************************************/
// Terminate
WBool Terminate( WDWord exitCode=0 );
// Wait
//
// Wait for the process to terminate, with a timeout in
// milliseconds. By default the timeout is infinite.
// If blockMessageProcessing is TRUE, then no messages will be
// responded to by this thread until the call to Wait() finishes.
WBool Wait(); // 0xFFFFFFFF, TRUE
WBool Wait( WDWord timeout,
WBool blockMessageProcessing );
};
//
// WCurrentProcess -- Represents the currently-running process.
//
class WCMCLASS WCurrentProcess : public WProcessBase {
WDeclareSubclass( WCurrentProcess, WProcessBase );
public:
WCurrentProcess();
WCurrentProcess( const WCurrentProcess & thd );
~WCurrentProcess(); // does not terminate process!
WCurrentProcess& operator=( const WCurrentProcess & thd );
/***********************************************************
* Properties
***********************************************************/
/***********************************************************
* Methods
***********************************************************/
/***********************************************************
* Static Methods
***********************************************************/
// Create
static WProcess Create( const WChar *commandLine,
WThread *firstThread=NULL,
WPoint *startingPosition=NULL,
WSize *startingSize=NULL,
WShowStyle *startingShowStyle=NULL,
WDWord creationFlags=WPROCESS_NORMAL_PRIORITY_CLASS );
/***********************************************************
* Overrides
***********************************************************/
virtual WProcessHandle GetHandle() const;
virtual WDWord GetID() const;
};
//
// WProcess -- Represents an arbitrary process.
//
class WCMCLASS WProcess : public WProcessBase {
WDeclareSubclass( WProcess, WProcessBase );
public:
WProcess();
WProcess( WProcessHandle handle, WDWord processID,
WBool closeHandle=TRUE, WBool makeCopy=FALSE );
WProcess( const WProcess & thd );
WProcess( const WCurrentProcess & curr );
~WProcess(); // does not terminate process!
WProcess& operator=( const WProcess & thd );
WProcess& operator=( const WCurrentProcess & thd );
/***********************************************************
* Properties
***********************************************************/
/***********************************************************
* Methods
***********************************************************/
// Clear
//
// Resets the object, closing the low-level kernel
// handle if no one else is referencing the process.
void Clear();
// Create
//
// Creates a new process.
WBool Create( const WChar *commandLine, WThread *firstThread=NULL,
WPoint *startingPosition=NULL,
WSize *startingSize=NULL,
WShowStyle *startingShowStyle=NULL,
WDWord creationFlags=WPROCESS_NORMAL_PRIORITY_CLASS );
/***********************************************************
* Overrides
***********************************************************/
virtual WProcessHandle GetHandle() const;
virtual WDWord GetID() const;
/***********************************************************
* Data Members
***********************************************************/
private:
WProcessReference *_processRef;
};
#ifndef _WNO_PRAGMA_PUSH
#pragma enum pop;
#pragma pack(pop);
#endif
#endif // _WPROCESS_HPP_INCLUDED