added the helper functions

This commit is contained in:
Alekhya Kommuru
2020-01-14 15:00:05 -08:00
parent 5e30721e01
commit 969abe015c
3 changed files with 42 additions and 3 deletions

View File

@@ -77,4 +77,16 @@ std::wstring get_resource_string(UINT resource_id, HINSTANCE instance, const wch
// Requires that
// extern "C" IMAGE_DOS_HEADER __ImageBase;
// is added to the .cpp file.
#define GET_RESOURCE_STRING(resource_id) get_resource_string(resource_id, reinterpret_cast<HINSTANCE>(&__ImageBase), L#resource_id)
#define GET_RESOURCE_STRING(resource_id) get_resource_string(resource_id, reinterpret_cast<HINSTANCE>(&__ImageBase), L#resource_id)
// Function which takes a pointer ptr and allocates space before populating it with the string from the resource table
// using this approach as wstring cannot be cast to PCWSTR without allocating space
// hence, we have to malloc and free the pointer after each use
wchar_t* get_resource_string_wchar(UINT resource_id, HINSTANCE instance);
// Wrapper for getting a string from the resource file.
// Requires that
// extern "C" IMAGE_DOS_HEADER __ImageBase;
// is added to the .cpp file.
// used when the return type must be a wchar_t* instead of a wstring.
#define GET_RES_STRING_WCHAR(resource_id) get_resource_string_wchar(resource_id, reinterpret_cast<HINSTANCE>(&__ImageBase))