winapi_common
Public Types | Public Member Functions | Static Public Member Functions | List of all members
winapi::Process Class Reference

Create a new process or open an existing process. More...

Public Types

using ID = DWORD
 

Public Member Functions

ID get_id () const
 
const Handleget_handle () const
 
bool is_running () const
 
void wait () const
 
void terminate (int ec=0) const
 
void shut_down (int ec=0) const
 
int get_exit_code () const
 
std::string get_exe_path () const
 

Static Public Member Functions

static Process create (ProcessParameters)
 
static Process create (const CommandLine &)
 
static Process create (const CommandLine &, process::IO)
 
static Process shell (const ShellParameters &)
 
static Process shell (const CommandLine &)
 
static Process current ()
 
static Process open (ID id, DWORD permissions=default_permissions())
 
static Process open_r (ID)
 
static DWORD default_permissions ()
 
static DWORD read_permissions ()
 
static Resource get_resource (uint32_t id)
 
static std::string get_resource_string (uint32_t id)
 

Detailed Description

Create a new process or open an existing process.

Definition at line 54 of file process.hpp.

Member Function Documentation

◆ create() [1/3]

Process winapi::Process::create ( ProcessParameters  params)
static

Create a new process using ProcessParameters.

Definition at line 241 of file process.cpp.

◆ create() [2/3]

Process winapi::Process::create ( const CommandLine cmd_line)
static

Create a new process using the given command line.

Definition at line 245 of file process.cpp.

◆ create() [3/3]

Process winapi::Process::create ( const CommandLine cmd_line,
process::IO  io 
)
static

Create a new process using the given command line and IO settings.

Definition at line 250 of file process.cpp.

◆ shell() [1/2]

Process winapi::Process::shell ( const ShellParameters params)
static

Create a new shell process using ShellParameters.

Definition at line 256 of file process.cpp.

◆ shell() [2/2]

Process winapi::Process::shell ( const CommandLine cmd_line)
static

Create a new shell process using the given command line.

Definition at line 260 of file process.cpp.

◆ current()

Process winapi::Process::current ( )
static

Open the current process.

Definition at line 265 of file process.cpp.

◆ open()

Process winapi::Process::open ( ID  id,
DWORD  permissions = default_permissions() 
)
static

Open an existing process.

Parameters
idProcess ID.
permissionsRequired permissions.

Definition at line 269 of file process.cpp.

◆ open_r()

Process winapi::Process::open_r ( ID  id)
static

Open an existing process with read permissions.

Definition at line 273 of file process.cpp.

◆ default_permissions()

DWORD winapi::Process::default_permissions ( )
static

Permissions that allow to query process's status.

Definition at line 277 of file process.cpp.

◆ read_permissions()

DWORD winapi::Process::read_permissions ( )
static

Permissions that allows to read process's memory.

Definition at line 281 of file process.cpp.

◆ get_id()

ID winapi::Process::get_id ( ) const
inline

Get this process's ID.

Definition at line 87 of file process.hpp.

◆ get_handle()

const Handle& winapi::Process::get_handle ( ) const
inline

Get this process's handle.

Definition at line 89 of file process.hpp.

◆ is_running()

bool winapi::Process::is_running ( ) const

Check if this process is running (i.e. not terminated).

Definition at line 285 of file process.cpp.

◆ wait()

void winapi::Process::wait ( ) const

Wait for the process to terminate.

Definition at line 301 of file process.cpp.

◆ terminate()

void winapi::Process::terminate ( int  ec = 0) const

Make this process terminate with an exit code.

Definition at line 315 of file process.cpp.

◆ shut_down()

void winapi::Process::shut_down ( int  ec = 0) const

Same as calling terminate() and wait().

Definition at line 321 of file process.cpp.

◆ get_exit_code()

int winapi::Process::get_exit_code ( ) const

Get terminated process's exit code.

Definition at line 326 of file process.cpp.

◆ get_exe_path()

std::string winapi::Process::get_exe_path ( ) const

Get this process's executable path.

Definition at line 342 of file process.cpp.

◆ get_resource()

Resource winapi::Process::get_resource ( uint32_t  id)
static

Get a binary resource from the process's executable.

Definition at line 370 of file process.cpp.

◆ get_resource_string()

std::string winapi::Process::get_resource_string ( uint32_t  id)
static

Get a string resource from the process's executable.

Returns
UTF-8 string.

Definition at line 358 of file process.cpp.


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