NSProcessInfo
Inherits From:
NSObject
Conforms To:
NSObject (NSObject)
Declared In:
Foundation/NSProcessinfo.h
Class Description
The NSProcessInfo class provides methods to access process-wide information. An NSProcessInfo object can return such information as the arguments, environment variables, host name, or process name. TheprocessInfo
class method returns a shared NSProcessInfo object for the process. For example, the following line returns the NSProcessInfo object, which then provides the name of the current process:
NSString *processName = [[NSProcessInfo processInfo] processName];
NSProcessInfo also includes the operatingSystem
method, which returns an enum
constant identifying the operating system on which the process is executing.
- Getting an NSProcessInfo object
- + processInfo
- Returning process information
- - arguments
- - environment
- - hostName
- - processName
- - globallyUniqueString
- - environment
- - arguments
- Returning the host operating system
- - operatingSystem
- - operatingSystemName
- - operatingSystem
- Specifying a process name
- - setProcessName:
Class Methods
processInfo
+ (NSProcessInfo *)processInfo
Returns an initialized NSProcessInfo object for the process. An NSProcessInfo object is created the first time this method is invoked, and that same object is returned on each subsequent invocation.
Instance Methods
arguments
- (NSArray *)arguments
Returns the command line arguments as an array of NSStrings.
environment
- (NSDictionary *)environment
Returns a dictionary of variables for the environment from which the process was launched. The dictionary keys are the environment variable names.
globallyUniqueString
- (NSString *)globallyUniqueString
Returns a globally unique string to identify the process. This method uses the host name, process ID, and a time stamp to ensure that the string returned will be unique for the network. This method generates a new string each time it is invoked, so it also uses a counter to guarantee that strings created from the same process will be unique.
See also:
- processName
hostName
- (NSString *)hostName
Returns the name of the host system.
operatingSystem
- (unsigned int)operatingSystem
Returns one the contants below to indicate the operating system on which the process is executing:
NSWindowsNTOperatingSystem
NSWindows95OperatingSystem
NSSolarisOperatingSystem
NSHPUXOperatingSystem
NSMACHOperatingSystem
NSSunOSOperatingSystem
NSOSF1OperatingSystem
operatingSystemName
- (NSString *)operatingSystemName
<< Description forthcoming. >>
processName
- (NSString *)processName
Returns the name of the process. This name is used to register Application defaults and is used in error messages. It does not uniquely identify the process.
See also:
- setProcessName:
setProcessName:
- (void)setProcessName:
(NSString *)newName
Sets the name of the process to newName.
Warning: User defaults and other aspects of the environment might depend on the process name, so be very careful if you change it. Setting the process name in this manner is
not
thread-safe.
See also:
- processName
Copyright © 1997, Apple Computer, Inc. All rights reserved.