Volume Control
Application-specific hotkeys for Windows
VolumeControl.TypeExtensions.ProcessExtensions Class Reference

Extension methods for the Process class. More...

Collaboration diagram for VolumeControl.TypeExtensions.ProcessExtensions:

Static Public Member Functions

static bool HasExited (this Process p)
 This fixes a bug that microsoft hasn't fixed since at least Windows Vista that occurs when calling Process.HasExited.
DO NOT USE THE Process.HasExited PROPERTY, USE THIS INSTEAD! More...
 
static ? string GetMainModulePath (this Process process)
 Gets the full path to the specified Process, process . More...
 
static ? string GetMainModulePathWMI (this Process process)
 Gets the full path to the specified Process, process . More...
 

Detailed Description

Extension methods for the Process class.

Member Function Documentation

◆ GetMainModulePath()

static ? string VolumeControl.TypeExtensions.ProcessExtensions.GetMainModulePath ( this Process  process)
static

Gets the full path to the specified Process, process .

Using this instead of accessing Process.MainModule directly prevents exceptions when accessing a process built for a different architecture (32/64 bit)

Parameters
processProcess
Returns
The filepath of process if successful; otherwise null.

◆ GetMainModulePathWMI()

static ? string VolumeControl.TypeExtensions.ProcessExtensions.GetMainModulePathWMI ( this Process  process)
static

Gets the full path to the specified Process, process .

This method uses WMI to make an SQL query, and as such, is very slow! Use GetMainModulePath(Process) instead wherever possible.

Parameters
processProcess
Returns
The filepath of process if successful; otherwise null.

◆ HasExited()

static bool VolumeControl.TypeExtensions.ProcessExtensions.HasExited ( this Process  p)
static

This fixes a bug that microsoft hasn't fixed since at least Windows Vista that occurs when calling Process.HasExited.
DO NOT USE THE Process.HasExited PROPERTY, USE THIS INSTEAD!

Sources:
https://www.giorgi.dev/net/access-denied-process-bugs/
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-openprocess
https://docs.microsoft.com/en-ca/windows/win32/api/processthreadsapi/nf-processthreadsapi-getprocesstimes
https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-closehandle

Parameters
pProcess instance.
Returns
True if the process has exited, false if the process is still running.

The documentation for this class was generated from the following file: