pub struct Process { /* private fields */ }
Expand description
A handle to a running process.
Implementations§
Source§impl Process
impl Process
Sourcepub fn from_id(id: u32) -> WinResult<Process>
pub fn from_id(id: u32) -> WinResult<Process>
Creates a process handle from a PID. Requests all access permissions.
Sourcepub fn from_id_with_access(id: u32, access: Access) -> WinResult<Process>
pub fn from_id_with_access(id: u32, access: Access) -> WinResult<Process>
Creates a process handle from a PID. Requests the specified access permissions.
Sourcepub fn from_name(name: &str) -> WinResult<Process>
pub fn from_name(name: &str) -> WinResult<Process>
Creates a process handle from a name. Requests all access.
Sourcepub fn from_name_with_access(name: &str, access: Access) -> WinResult<Process>
pub fn from_name_with_access(name: &str, access: Access) -> WinResult<Process>
Creates a process handle from a name.
Sourcepub fn from_handle(handle: Handle) -> Process
pub fn from_handle(handle: Handle) -> Process
Creates a process handle from a handle.
Sourcepub fn all() -> WinResult<impl Iterator<Item = Process>>
pub fn all() -> WinResult<impl Iterator<Item = Process>>
Enumerates all running processes. Requests all access.
Sourcepub fn all_with_access(
access: Access,
) -> WinResult<impl Iterator<Item = Process>>
pub fn all_with_access( access: Access, ) -> WinResult<impl Iterator<Item = Process>>
Enumerates all running processes.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Returns true if the process is running.
Sourcepub fn name(&self) -> WinResult<String>
pub fn name(&self) -> WinResult<String>
Returns the unqualified name of the executable of the process.
Sourcepub fn priority(&self) -> WinResult<PriorityClass>
pub fn priority(&self) -> WinResult<PriorityClass>
Returns the priority class of the process.
The handle must have the PROCESS_QUERY_INFORMATION
or PROCESS_QUERY_LIMITED_INFORMATION
access right.
Sourcepub fn set_priority(&mut self, priority: PriorityClass) -> WinResult
pub fn set_priority(&mut self, priority: PriorityClass) -> WinResult
Sets the priority class of the process.
The handle must have the PROCESS_SET_INFORMATION
access right.
Sourcepub fn start_background_mode(&mut self) -> WinResult
pub fn start_background_mode(&mut self) -> WinResult
Begins background processing mode.
This can be initiated only if the handle refers to the current process.
The system lowers the resource scheduling priorities of the process (and its threads) so that it can perform background work without significantly affecting activity in the foreground.
The function fails if the process is already in background processing mode.
The handle must have the PROCESS_SET_INFORMATION
access right.
Sourcepub fn end_background_mode(&mut self) -> WinResult
pub fn end_background_mode(&mut self) -> WinResult
Ends background processing mode.
This can be initiated only if the handle refers to the current process.
The system restores the resource scheduling priorities of the process (and its threads) as they were before the process entered background processing mode.
The function fails if the process is not in background processing mode.
The handle must have the PROCESS_SET_INFORMATION
access right.
Sourcepub fn terminate(&mut self, exit_code: u32) -> WinResult
pub fn terminate(&mut self, exit_code: u32) -> WinResult
Terminates the process.
The handle must have the PROCESS_TERMINATE
access right.
Sourcepub fn affinity_mask(&self) -> WinResult<usize>
pub fn affinity_mask(&self) -> WinResult<usize>
Returns the affinity mask of the process.
Sourcepub fn set_affinity_mask(&mut self, mask: u32) -> WinResult
pub fn set_affinity_mask(&mut self, mask: u32) -> WinResult
Sets the affinity mask of the process.
A process affinity mask is a bit vector in which each bit represents a logical processor that a process is allowed to run on.
Setting an affinity mask for a process or thread can result in threads receiving less processor time, as the system is restricted from running the threads on certain processors. In most cases, it is better to let the system select an available processor.
If the new process affinity mask does not specify the processor that is currently running the process, the process is rescheduled on one of the allowable processors.
Sourcepub fn threads<'a>(&'a self) -> WinResult<impl Iterator<Item = Thread> + 'a>
pub fn threads<'a>(&'a self) -> WinResult<impl Iterator<Item = Thread> + 'a>
Returns an iterator over the threads of the process.
Sourcepub fn thread_ids<'a>(&'a self) -> WinResult<impl Iterator<Item = u32> + 'a>
pub fn thread_ids<'a>(&'a self) -> WinResult<impl Iterator<Item = u32> + 'a>
Returns an iterator over the ids of threads of the process.
Sourcepub fn module<N: AsRef<OsStr>>(&self, name: N) -> WinResult<Module<'_>>
pub fn module<N: AsRef<OsStr>>(&self, name: N) -> WinResult<Module<'_>>
Returns the loaded module with the specified name/path.
Sourcepub fn module_list(&self) -> WinResult<Vec<Module<'_>>>
pub fn module_list(&self) -> WinResult<Vec<Module<'_>>>
Returns a list of the modules of the process.
Sourcepub fn module_entries<'a>(
&'a self,
) -> WinResult<impl Iterator<Item = ModuleEntry> + 'a>
pub fn module_entries<'a>( &'a self, ) -> WinResult<impl Iterator<Item = ModuleEntry> + 'a>
Returns an iterator over the modules of the process.