aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/process.hpp
blob: c27dc3ea51e3c1319cef0aa8e55baa1a0513b882 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2016 Egor Tensin <Egor.Tensin@gmail.com>
// This file is part of the "Privilege check" project.
// For details, see https://github.com/egor-tensin/privilege-check.
// Distributed under the MIT License.

#pragma once

#include "error.hpp"
#include "cmd_line.hpp"

#include <windows.h>

#include <string>

namespace process
{
    inline HMODULE load_exe_module()
    {
        const auto module = GetModuleHandle(NULL);
        if (module == NULL)
            error::raise("GetModuleHandle");
        return module;
    }

    std::wstring get_executable_path();

    inline std::wstring get_command_line()
    {
        return GetCommandLine();
    }

    void runas(
        const CommandLine& cmd_line,
        HWND hwnd = NULL,
        int nShow = SW_NORMAL);

    void runas_self(
        HWND hwnd = NULL,
        int nShow = SW_NORMAL);
}