static PProcess& Current()
- Get the current processes object instance. The current process
is the one the application is running in.
- Returns:
- pointer to current process instance.
static BOOL IsInitialised()
- Determine if the current processes object instance has been initialised.
If this returns TRUE it is safe to use the PProcess::Current() function.
- Returns:
- TRUE if process class has been initialised.
void SetTerminationValue( int value )
- Set the termination value for the process.
The termination value is an operating system dependent integer which
indicates the processes termiantion value. It can be considered a
"return value" for an entire programme.
- Parameters:
- - value Value to return a process termination status.
int GetTerminationValue() const
- Get the termination value for the process.
The termination value is an operating system dependent integer which
indicates the processes termiantion value. It can be considered a
"return value" for an entire programme.
- Returns:
- integer termination value.
PArgList& GetArguments()
- Get the programme arguments. Programme arguments are a set of strings
provided to the programme in a platform dependent manner.
- Returns:
- argument handling class instance.
virtual const PString& GetManufacturer() const
- Get the name of the manufacturer of the software. This is used in the
default "About" dialog box and for determining the location of the
configuration information as used by the PConfig class.
The default for this information is the empty string.
- Returns:
- string for the manufacturer name eg "Equivalence".
virtual const PString& GetName() const
- Get the name of the process. This is used in the
default "About" dialog box and for determining the location of the
configuration information as used by the PConfig class.
The default is the title part of the executable image file.
- Returns:
- string for the process name eg "MyApp".
virtual PString GetVersion( BOOL full = TRUE ) const
- Get the version of the software. This is used in the default "About"
dialog box and for determining the location of the configuration
information as used by the PConfig class.
If the full parameter is TRUE then a version string
built from the major, minor, status and build veriosn codes is
returned. If FALSE then only the major and minor versions are
returned.
The default for this information is "1.0".
- Parameters:
- full - TRUE for full version, FALSE for short version.
- Returns:
- string for the version eg "1.0b3".
const PFilePath& GetFile() const
- Get the processes executable image file path.
- Returns:
- file path for program.
DWORD GetProcessID() const
- Get the platform dependent process identifier for the process. This is
an arbitrary (and unique) integer attached to a process by the operating
system.
- Returns:
- Process ID for process.
PString GetUserName() const
- Get the effective user name of the owner of the process, eg "root" etc.
This is a platform dependent string only provided by platforms that are
multi-user. Note that some value may be returned as a "simulated" user.
For example, in MS-DOS an environment variable
- Returns:
- user name of processes owner.
BOOL SetUserName( const PString & username, BOOL permanent = FALSE )
- Set the effective owner of the process.
This is a platform dependent string only provided by platforms that are
multi-user.
For unix systems if the username may consist exclusively of digits and
there is no actual username consisting of that string then the numeric
uid value is used. For example "0" is the superuser. For the rare
occassions where the users name is the same as their uid, if the
username field starts with a '' then the numeric form is forced.
If an empty string is provided then original user that executed the
process in the first place (the real user) is set as the effective user.
The permanent flag indicates that the user will not be able to simple
change back to the original user as indicated above, ie for unix
systems setuid() is used instead of seteuid(). This is not necessarily
meaningful for all platforms.
- Parameters:
- username - New user name or uid
permanent - Flag for if effective or real user
- Returns:
- TRUE if processes owner changed. The most common reason for failure is
that the process does not have the privilege to change the effective user.
PString GetGroupName() const
- Get the effective group name of the owner of the process, eg "root" etc.
This is a platform dependent string only provided by platforms that are
multi-user. Note that some value may be returned as a "simulated" user.
For example, in MS-DOS an environment variable
- Returns:
- group name of processes owner.
BOOL SetGroupName( const PString & groupname, BOOL permanent = FALSE )
- Set the effective group of the process.
This is a platform dependent string only provided by platforms that are
multi-user.
For unix systems if the groupname may consist exclusively of digits and
there is no actual groupname consisting of that string then the numeric
uid value is used. For example "0" is the superuser. For the rare
occassions where the groups name is the same as their uid, if the
groupname field starts with a '' then the numeric form is forced.
If an empty string is provided then original group that executed the
process in the first place (the real group) is set as the effective
group.
The permanent flag indicates that the group will not be able to simply
change back to the original group as indicated above, ie for unix
systems setgid() is used instead of setegid(). This is not necessarily
meaningful for all platforms.
- Parameters:
- groupname - New group name or gid
permanent - Flag for if effective or real group
- Returns:
- TRUE if processes group changed. The most common reason for failure is
that the process does not have the privilege to change the effective
group.
int GetMaxHandles() const
- Get the maximum file handle value for the process.
For some platforms this is meaningless.
- Returns:
- user name of processes owner.
BOOL SetMaxHandles( int newLimit )
- Set the maximum number of file handles for the process.
For unix systems the user must be run with the approriate privileges
before this function can set the value above the system limit.
For some platforms this is meaningless.
- Parameters:
- newLimit - New limit on file handles
- Returns:
- TRUE if successfully set the maximum file hadles.
virtual PString GetConfigurationFile()
- Get the default file to use in PConfig instances
void SetConfigurationPath( const PString & path )
- Set the default file or set of directories to search for use in PConfig.
To find the .ini file for use in the default PConfig() instance, this
explicit filename is used, or if it is a set of directories separated
by either ':' or ';' characters, then the application base name postfixed
with ".ini" is searched for through those directories.
The search is actually done when the GetConfigurationFile() is called,
this function only sets the internal variable.
Note for Windows, a path beginning with "HKEY_LOCAL_MACHINE
" or
"HKEY_CURRENT_USER
" will actually search teh system registry for the
application base name only (no ".ini") in that folder of the registry.
- Parameters:
- - path Explicit file or set of directories