diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-09-16 01:08:49 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-09-16 01:08:49 +0300 |
commit | 42f1ad36ef93c98542f9899ada57bd55396a99f5 (patch) | |
tree | d0b10dd617764271db739b608a9d6bfaa63d516b /process.h | |
parent | make the 'Elevate' button smaller (diff) | |
download | privilege-check-42f1ad36ef93c98542f9899ada57bd55396a99f5.tar.gz privilege-check-42f1ad36ef93c98542f9899ada57bd55396a99f5.zip |
.hpp instead of .h for C++ headers
Diffstat (limited to 'process.h')
-rw-r--r-- | process.h | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/process.h b/process.h deleted file mode 100644 index 9aaf319..0000000 --- a/process.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include "error.h" - -#include <Windows.h> -#include <shellapi.h> - -#include <array> -#include <string> - -namespace process -{ - std::wstring get_executable_path() - { - static constexpr DWORD max_path = MAX_PATH; - - std::array<wchar_t, max_path> buf; - - const auto ret = GetModuleFileNameW(NULL, buf.data(), max_path); - - if (GetLastError() != ERROR_SUCCESS) - error::raise("GetModuleFileNameW"); - - return buf.data(); - } - - void runas(const std::wstring& exe_path, HWND hwnd = NULL, int nShow = SW_NORMAL) - { - SHELLEXECUTEINFOW info; - ZeroMemory(&info, sizeof(info)); - info.cbSize = sizeof(info); - info.lpVerb = L"runas"; - info.lpFile = exe_path.c_str(); - info.hwnd = hwnd; - info.nShow = nShow; - - if (!ShellExecuteExW(&info)) - error::raise("ShellExecuteExW"); - } -} |