winapi 读取二进制资源文件

 1 static char *get_resource(char *id, unsigned *size)
 2 {
 3     HRSRC hr = FindResource(GetModuleHandle(NULL), id, RT_RCDATA);
 4     
 5     if (hr == NULL) return NULL;
 6     *size = SizeofResource(GetModuleHandle(NULL), hr);
 7     h = LoadResource(GetModuleHandle(NULL), hr);
 8     return (char *)LockResource(h);
 9 }
10 
11 static void free_resource(void)
12 {
13     if (h)
14     {
15         FreeResource(h);
16         h = 0;
17     }
18 }

 

posted @ 2020-09-06 00:00  天天2023  阅读(298)  评论(0)    收藏  举报