public class Process extends Handle implements com.jniwrapper.AutoDeleteParameter
NOTE: Every created or opened process should be closed using the close()
method.
Modifier and Type | Class and Description |
---|---|
static class |
Process.PriorityClass
PrioriryClass class is enumeration of priorities for a system process.
|
protected static class |
Process.ProcessResource
This class responds for destroying a native resource when the instance is collected by garbage-collector.
|
INFINITE_TIMEOUT, INVALID_HANDLE_VALUE, STATUS_ABANDONED_WAIT_0, STATUS_TIMEOUT, STATUS_WAIT_0
Constructor and Description |
---|
Process(java.lang.String commandLine)
Creates a new process and its primary thread.
|
Process(java.lang.String applicationName,
java.lang.String commandLine,
ProcessOptions options,
java.lang.String currentDirectory,
StartupInfo startupInfo)
Creates a new process and its primary thread.
|
Process(java.lang.String applicationName,
java.lang.String commandLine,
SecurityAttributes processAttributes,
SecurityAttributes threadAttributes,
boolean inheritHandles,
ProcessOptions options,
ProcessVariables environment,
java.lang.String currentDirectory,
StartupInfo startupInfo)
Creates a new process and its primary thread.
|
Process(java.lang.String userName,
java.lang.String domain,
java.lang.String password,
boolean logonWithProfile,
java.lang.String applicationName,
java.lang.String commandLine,
ProcessOptions options,
ProcessVariables environment,
java.lang.String currentDirectory,
StartupInfo startupInfo)
Creates a new process and its primary thread.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the opened process safely and all associated handles.
|
long |
getAffinityMask()
Returns the process affinity mask for the specified process and the system affinity mask for the system.
|
static java.util.List |
getApplicationWindows() |
long |
getExitCode()
Returns the termination status of the process.
|
long |
getGdiObjectsCount()
Returns the count of GDI objects.
|
long |
getHandleCount()
Returns the number of open handles that belong to the specified process.
|
IOCounters |
getIOCounters()
Returns accounting information for all I/O operations performed by the specified process.
|
java.lang.String |
getModuleFileName(Handle module)
Gets the file name of the specified module attached to the process.
|
java.util.List |
getModules()
Gets the list of handles of the modules attached to the process.
|
boolean |
getPriorityBoost()
Returns the priority boost control state of the process.
|
Process.PriorityClass |
getPriorityClass()
Returns the priority class for the specified process.
|
static java.util.List |
getProcesses()
Gets a list of all running processes.
|
static java.util.List |
getProcesses(ProcessSecurityOptions processSecurityOptions)
Gets a list of all running processes with the specified
ProcessSecurityOptions . |
java.lang.String |
getProcessFileName()
Returns the name of the executable file for this process.
|
long |
getProcessID()
Returns the identifier of the process.
|
static long |
getProcessID(Process process)
Returns the identifier of the process.
|
java.lang.String |
getProcessImageFileName()
Returns the name of the executable file for this process.
|
ProcessMemoryCounters |
getProcessMemoryCounters()
Returns information about the memory usage of this process.
|
void |
getProcessTimes(FileTime creationTime,
FileTime exitTime,
FileTime kernelTime,
FileTime userTime)
Returns timing information about the specified process.
|
long |
getSystemAffinityMask()
Returns the system affinity mask for the system.
|
Handle |
getThread()
Returns a Handle to the primary thread of the process.
|
long |
getThreadID()
Returns the identifier of the thread.
|
static long |
getThreadID(Handle thread)
Returns the identifier of the thread.
|
static long |
getThreadProcessID(Handle thread)
Returns the process identifier of the process associated with a specified thread.
|
long |
getUSERObjectsCount()
Returns the count of USER objects.
|
long |
getVersion()
Returns the major and minor version numbers of the system on which the specified process expects to run.
|
static long |
getVersion(long processID)
Returns the major and minor version numbers of the system on which the specified process expects to run.
|
void |
getWorkingSetSize(com.jniwrapper.UInt32 minimumWorkingSetSize,
com.jniwrapper.UInt32 maximumWorkingSetSize)
Returns the minimum and maximum working set sizes of the specified process.
|
boolean |
isAutoDelete() |
static Process |
openProcess(ProcessSecurityOptions desiredAccess,
boolean inheritHandle,
long processID)
Opens an existing process object.
|
protected void |
registerResource()
Registers process handle to be garbage-collected automatically.
|
void |
setAffinityMask(long affinityMask)
Sets a processor affinity mask for the threads of the process.
|
void |
setAutoDelete(boolean autoDelete) |
void |
setPriorityBoost(boolean enable)
Enables or disables the ability of the system to temporarily boost the priority of the threads of the process.
|
void |
setPriorityClass(Process.PriorityClass prioriryClass)
Sets the priority class for the specified process.
|
void |
setWorkingSetSize(long minSize,
long maxSize)
Sets the minimum and maximum working set sizes for the specified process.
|
void |
terminate(long exitCode)
Terminates the process and all of its threads.
|
long |
waitFor()
Causes the current thread to wait, if necessary, until the
process represented by this
Process object has
terminated. |
long |
waitFor(long timeout)
Causes the current thread to wait, if necessary, until the
process represented by this
Process object has
terminated. |
clone, closeHandle, equals, waitFor, waitFor
asFunction, asFunction, asTypedPointer, castTo, castTo, getDebugInfo, getLength, getValue, hashCode, isNull, read, setValue, toString, write
public Process(java.lang.String commandLine)
commandLine
- Can be null; specifies the command line to execute.public Process(java.lang.String applicationName, java.lang.String commandLine, ProcessOptions options, java.lang.String currentDirectory, StartupInfo startupInfo)
applicationName
- Can be null; specifies the module to execute in which case the executable name must be in the white space-delimited string pointed to by CommandLine.commandLine
- Can be null; specifies the command line to execute.options
- Options that control the priority class and the creation of the process.currentDirectory
- Can be null; specifies the current drive and directory for the new process.public Process(java.lang.String applicationName, java.lang.String commandLine, SecurityAttributes processAttributes, SecurityAttributes threadAttributes, boolean inheritHandles, ProcessOptions options, ProcessVariables environment, java.lang.String currentDirectory, StartupInfo startupInfo)
applicationName
- Can be null; specifies the module to execute in which case the executable name must be in the white space-delimited string pointed to by CommandLine.commandLine
- Can be null; specifies the command line to execute.processAttributes
- Can be null; determines whether the returned handle can be inherited by child processes.threadAttributes
- Can be null; determines whether the returned handle can be inherited by child processes.inheritHandles
- If this parameter is true, each inheritable handle in the calling process is inherited by the new process. If the parameter is false, the handles are not inherited.options
- Options that control the priority class and the creation of the process.environment
- Can be null; environment block for the new process; If this parameter is null, the new process uses the environment of the calling process.currentDirectory
- Can be null; specifies the current drive and directory for the new process.startupInfo
- Specifies the window station, desktop, standard handles, and appearance of the main window for the new process.public Process(java.lang.String userName, java.lang.String domain, java.lang.String password, boolean logonWithProfile, java.lang.String applicationName, java.lang.String commandLine, ProcessOptions options, ProcessVariables environment, java.lang.String currentDirectory, StartupInfo startupInfo)
userName
- Specifies the name of the user.domain
- Can be null; specifies the name of the domain or server whose account database contains the lpUsername account.password
- Specifies the clear-text password for the lpUsername account.logonWithProfile
- Specifies the way to logon. True specifies logon with profile, false - logon with net credentials only.applicationName
- Can be null; specifies the module to execute in which case the executable name must be in the white space-delimited string pointed to by CommandLine.commandLine
- Can be null; specifies the command line to execute.options
- Options that control the priority class and the creation of the process.environment
- Can be null; environment block for the new process; If this parameter is null, the new process uses the environment of the calling process.currentDirectory
- Can be null; specifies the current drive and directory for the new process.startupInfo
- Specifies the window station, desktop, standard handles, and appearance of the main window for the new process.public static Process openProcess(ProcessSecurityOptions desiredAccess, boolean inheritHandle, long processID)
desiredAccess
- Access rights to the process object.inheritHandle
- If this parameter is true, the handle is inheritable. Otherwise the handle cannot be inherited.processID
- ID of the process to open.protected void registerResource()
public static long getProcessID(Process process)
IMPORTANT NOTE: This function is available in WinXP (since SP1) and WinServer 2003 only.
public long getExitCode()
public void setAutoDelete(boolean autoDelete)
setAutoDelete
in interface com.jniwrapper.AutoDeleteParameter
public boolean isAutoDelete()
isAutoDelete
in interface com.jniwrapper.AutoDeleteParameter
public Process.PriorityClass getPriorityClass()
public void setPriorityClass(Process.PriorityClass prioriryClass)
prioriryClass
- Priority class for the processpublic long getGdiObjectsCount()
public long getUSERObjectsCount()
public long getHandleCount()
public IOCounters getIOCounters()
public void getProcessTimes(FileTime creationTime, FileTime exitTime, FileTime kernelTime, FileTime userTime)
creationTime
- [out] the creation time of the process.exitTime
- [out] the exit time of the process.kernelTime
- [out] the amount of time that the process has executed in kernel mode.userTime
- [out] the amount of time that the process has executed in user mode.public void setPriorityBoost(boolean enable)
enable
- If this parameter is true, dynamic boosting is enabled. If the parameter is false, dynamic boosting is disabled.public boolean getPriorityBoost()
public void terminate(long exitCode)
exitCode
- the process exit code.public long getVersion()
public static long getVersion(long processID)
processID
- identifier of the process.public void getWorkingSetSize(com.jniwrapper.UInt32 minimumWorkingSetSize, com.jniwrapper.UInt32 maximumWorkingSetSize)
The "Working Set" of a process is a set of memory pages currently visible to the process in physical RAM memory. These pages are resident and available for an application to use without triggering a page fault. The minimum and maximum working set sizes affect the virtual memory paging behavior of a process.
minimumWorkingSetSize
- [out] Minimum working set size for the process, in bytes.maximumWorkingSetSize
- [out] Maximum working set size for the process, in bytes.public void setWorkingSetSize(long minSize, long maxSize)
The "Working Set" of a process is a set of memory pages currently visible to the process in physical RAM memory. These pages are resident and available for an application to use without triggering a page fault. The minimum and maximum working set sizes affect the virtual memory paging behavior of a process.
minSize
- Minimum working set size for the process, in bytes.maxSize
- Maximum working set size for the process, in bytes.public long getAffinityMask()
A process affinity mask is a bit vector in which each bit represents the processors that a process is allowed to run on.
public long getSystemAffinityMask()
A system affinity mask is a bit vector in which each bit represents the processors that are configured into a system.
public void setAffinityMask(long affinityMask)
affinityMask
- Affinity mask for the threads of the process.public static long getThreadProcessID(Handle thread)
thread
- Handle of the thread.public static long getThreadID(Handle thread)
thread
- Handle to the thread.public long waitFor(long timeout)
Process
object has
terminated.timeout
- Time-out interval, in milliseconds.public long waitFor()
Process
object has
terminated.public long getThreadID()
public long getProcessID()
public Handle getThread()
public void close()
public ProcessMemoryCounters getProcessMemoryCounters()
public java.lang.String getProcessImageFileName()
getProcessFileName()
method.public java.lang.String getProcessFileName()
public static java.util.List getProcesses()
Process
class instance.Process
class instances.public static java.util.List getProcesses(ProcessSecurityOptions processSecurityOptions)
ProcessSecurityOptions
. Each process is represented by
Process
class instance.processSecurityOptions
- security options for all the processes of the list.Process
class instances.public java.util.List getModules()
public java.lang.String getModuleFileName(Handle module)
module
- is the handle of the module attached to the process.public static java.util.List getApplicationWindows()