From def5c50960eea4c112647f88361a3ae7155901a8 Mon Sep 17 00:00:00 2001 From: egor-tensin Date: Tue, 4 Jul 2023 00:48:00 +0000 Subject: =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20egor-tensin/wina?= =?UTF-8?q?pi-common@0c196cbe8b4927c78c02b2c7312fc69a507db845=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- process_8hpp_source.html | 193 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 process_8hpp_source.html (limited to 'process_8hpp_source.html') diff --git a/process_8hpp_source.html b/process_8hpp_source.html new file mode 100644 index 0000000..a7e9a14 --- /dev/null +++ b/process_8hpp_source.html @@ -0,0 +1,193 @@ + + + + + + + +winapi_common: include/winapi/process.hpp Source File + + + + + + + + + +
+
+ + + + + + +
+
winapi_common +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
process.hpp
+
+
+
1 // Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
+
2 // This file is part of the "winapi-common" project.
+
3 // For details, see https://github.com/egor-tensin/winapi-common.
+
4 // Distributed under the MIT License.
+
5 
+
6 #pragma once
+
7 
+
8 #include "cmd_line.hpp"
+
9 #include "handle.hpp"
+
10 #include "process_io.hpp"
+
11 #include "resource.hpp"
+
12 
+
13 #include <boost/optional.hpp>
+
14 
+
15 #include <windows.h>
+
16 
+
17 #include <cstdint>
+
18 #include <string>
+
19 #include <utility>
+
20 
+
21 namespace winapi {
+
22 
+ +
25  enum ConsoleCreationMode {
+
26  ConsoleNone,
+
27  ConsoleInherit,
+
28  ConsoleNew,
+
29  };
+
30 
+
31  explicit ProcessParameters(const CommandLine& cmd_line) : cmd_line{cmd_line} {}
+
32 
+
33  CommandLine cmd_line;
+
34  boost::optional<process::IO> io;
+
35  ConsoleCreationMode console_mode = ConsoleNew;
+
36 };
+
37 
+ +
40  static ShellParameters runas(const CommandLine& cmd_line) {
+
41  ShellParameters params{cmd_line};
+
42  params.verb = "runas";
+
43  return params;
+
44  }
+
45 
+
46  explicit ShellParameters(const CommandLine& cmd_line) : ProcessParameters{cmd_line} {}
+
47 
+
48  boost::optional<std::string> verb;
+
49 };
+
50 
+
54 class Process {
+
55 public:
+
56  using ID = DWORD;
+
57 
+ +
61  static Process create(const CommandLine&);
+
63  static Process create(const CommandLine&, process::IO);
+
64 
+
66  static Process shell(const ShellParameters&);
+
68  static Process shell(const CommandLine&);
+
69 
+
71  static Process current();
+
77  static Process open(ID id, DWORD permissions = default_permissions());
+
79  static Process open_r(ID);
+
80 
+
82  static DWORD default_permissions();
+
84  static DWORD read_permissions();
+
85 
+
87  ID get_id() const { return m_id; }
+
89  const Handle& get_handle() const { return m_handle; }
+
90 
+
92  bool is_running() const;
+
94  void wait() const;
+
96  void terminate(int ec = 0) const;
+
98  void shut_down(int ec = 0) const;
+
100  int get_exit_code() const;
+
101 
+
103  std::string get_exe_path() const;
+
104 
+
106  static Resource get_resource(uint32_t id);
+
111  static std::string get_resource_string(uint32_t id);
+
112 
+
113 private:
+
114  explicit Process(Handle&& handle);
+
115  Process(ID, Handle&& handle);
+
116 
+
117  static HMODULE get_exe_module();
+
118 
+
119  ID m_id;
+
120  Handle m_handle;
+
121 };
+
122 
+
123 } // namespace winapi
+
Command line for the current process or for launching new processes.
Definition: cmd_line.hpp:21
+
HANDLE wrapper.
Definition: handle.hpp:25
+
Create a new process or open an existing process.
Definition: process.hpp:54
+
void terminate(int ec=0) const
Definition: process.cpp:315
+
void shut_down(int ec=0) const
Definition: process.cpp:321
+
const Handle & get_handle() const
Definition: process.hpp:89
+
void wait() const
Definition: process.cpp:301
+
int get_exit_code() const
Definition: process.cpp:326
+
static Process open(ID id, DWORD permissions=default_permissions())
Definition: process.cpp:269
+
static Resource get_resource(uint32_t id)
Definition: process.cpp:370
+
static Process current()
Definition: process.cpp:265
+
static DWORD read_permissions()
Definition: process.cpp:281
+
static DWORD default_permissions()
Definition: process.cpp:277
+
bool is_running() const
Definition: process.cpp:285
+
static Process create(ProcessParameters)
Definition: process.cpp:241
+
std::string get_exe_path() const
Definition: process.cpp:342
+
ID get_id() const
Definition: process.hpp:87
+
static Process shell(const ShellParameters &)
Definition: process.cpp:256
+
static std::string get_resource_string(uint32_t id)
Definition: process.cpp:358
+
static Process open_r(ID)
Definition: process.cpp:273
+
Process parameters for Process::create().
Definition: process.hpp:24
+
Resources embedded in a PE (Portable Executable).
Definition: resource.hpp:15
+
Process parameters for Process::shell().
Definition: process.hpp:39
+
Child process IO settings.
Definition: process_io.hpp:61
+
+ + + + -- cgit v1.2.3