8#include "win32_error_intf.hpp"
11#include <system_error>
13hi_export_module(hikogui.win32 : processthreadsapi);
15hi_export
namespace hi {
18[[nodiscard]]
inline std::expected<uint32_t, win32_error> win32_GetExitCodeProcess(HANDLE process_handle)
noexcept
21 if (GetExitCodeProcess(process_handle, &exit_code)) {
22 if (exit_code == STILL_ACTIVE) {
32template<
typename StartupInfo>
33[[nodiscard]]
inline std::expected<PROCESS_INFORMATION, win32_error> win32_CreateProcess(
34 std::optional<std::string> application_name,
35 std::optional<std::string> command_line,
36 SECURITY_ATTRIBUTES
const *process_attributes,
37 SECURITY_ATTRIBUTES
const *thread_attributes,
39 uint32_t creation_flags,
40 void const *environment,
41 std::optional<std::string> current_directory,
42 StartupInfo
const &startup_info)
45 wchar_t const *application_name_cstr =
nullptr;
46 if (application_name) {
48 application_name_wstr = *application_name_wstr_;
49 application_name_cstr = application_name_wstr.
c_str();
56 wchar_t *command_line_cstr =
nullptr;
59 command_line_wstr = *command_line_wstr_;
60 command_line_cstr = command_line_wstr.
data();
67 wchar_t *current_directory_cstr =
nullptr;
68 if (current_directory) {
70 current_directory_wstr = *current_directory_wstr_;
71 current_directory_cstr = current_directory_wstr.
data();
77 auto r = PROCESS_INFORMATION{};
79 if (not CreateProcessW(
80 application_name_cstr,
82 const_cast<SECURITY_ATTRIBUTES *
>(process_attributes),
83 const_cast<SECURITY_ATTRIBUTES *
>(thread_attributes),
85 static_cast<DWORD
>(creation_flags),
86 const_cast<void *
>(environment),
87 current_directory_cstr,
88 const_cast<STARTUPINFOW *
>(
reinterpret_cast<STARTUPINFOW
const *
>(&startup_info)),
Rules for working with win32 headers.
The HikoGUI namespace.
Definition array_generic.hpp:20
std::expected< std::wstring, win32_error > win32_MultiByteToWideChar(std::string_view s, unsigned int code_page=CP_UTF8, uint32_t flags=0) noexcept
Convert a win32-API compatible std::wstring to a multi-byte std::string.
Definition stringapiset.hpp:58
DOXYGEN BUG.
Definition algorithm_misc.hpp:20