aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/src/resource.hpp
blob: a0f1cc374c7a62ed0f52190e97e2519377da9625 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                                         

                                                                   

                                     

            


                      
                    
 

                  



                  











                                                    
 

                                                  
 
// 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 "process.hpp"

#include <Windows.h>

#include <cstddef>

#include <string>

namespace resource
{
    inline std::wstring load_string(unsigned int id)
    {
        wchar_t* s = nullptr;

        const auto ret = LoadStringW(
            process::load_exe_module(),
            id,
            reinterpret_cast<wchar_t*>(&s),
            0);

        if (ret <= 0)
            error::raise("LoadStringW");

        return {s, static_cast<std::size_t>(ret)};
    }
}