19 if (hInstance ==
nullptr) {
20 hInstance = GetModuleHandleA(NULL);
22 HRSRC res = FindResourceA(hInstance, MAKEINTRESOURCEA(res_id), res_type);
25 std::cerr <<
"Cannot find resource" << std::endl;
29 HGLOBAL res_handle = LoadResource(hInstance, res);
30 if (res_handle ==
nullptr) {
32 std::cerr <<
"Cannot get resource handle" << std::endl;
36 BYTE* res_data = (BYTE*) LockResource(res_handle);
37 size_t r_size =
static_cast<size_t>(SizeofResource(hInstance, res));
38 if (out_size != 0 && out_size <= r_size) {
43 if (out_buf !=
nullptr) {
44 memcpy(out_buf, res_data, r_size);
49 FreeResource(res_handle);