cgv
Loading...
Searching...
No Matches
resources.cxx
1#include "resources.h"
2#include <iostream>
3
4#ifdef WIN32
5#include <Windows.h>
6
7const char* resource_type_name(unsigned i)
8{
9 static const char* resource_type_names[] = {
10 "",
11 "Cursor",
12 "Bitmap",
13 "Icon",
14 "Menu",
15 "Dialog",
16 "String",
17 "FontDir",
18 "Font",
19 "Accelerator",
20 "RawData",
21 "MessageTable",
22 "GroupCoursor",
23 "",
24 "GroupIcon",
25 "",
26 "Version",
27 "DLGInclude",
28 "",
29 "PlugAndPlay",
30 "VXD",
31 "Animated cursor",
32 "AnimatedIcon",
33 "HTML",
34 "Manifest"
35 };
36 return resource_type_names[i];
37}
38enum class RessourceType
39{
40 CURSOR = 1,
41 BITMAP = 2,
42 ICON = 3,
43 MENU = 4,
44 DIALOG = 5,
45 STRING = 6,
46 FONTDIR = 7,
47 FONT = 8,
48 ACCELERATOR = 9,
49 RCDATA = 10,
50 MESSAGETABLE = 11,
51 GROUP_CURSOR = 12,
52 GROUP_ICON = 14,
53 VERSION = 16,
54 DLGINCLUDE = 17,
55 PLUGPLAY = 19,
56 VXD = 20,
57 ANICURSOR = 21,
58 ANIICON = 22,
59 HTML = 23,
60 MANIFEST = 24
61};
62
63BOOL EnumLangsFunc(HMODULE hModule, LPCTSTR lpType, LPCTSTR lpName, WORD wLang, LONG lParam)
64{
65 HRSRC hResInfo;
66 hResInfo = FindResourceEx(hModule, lpType, lpName, wLang);
67 std::cout << " Language: " << (USHORT)wLang;
68 std::cout << " ResInfo: " << hResInfo << " Size = " << (USHORT)wLang << std::endl;
69 return TRUE;
70}
71
72BOOL EnumNamesFunc(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG lParam)
73{
74 if (IS_INTRESOURCE(lpName))
75 std::cout << " Name:" << (USHORT)lpName << std::endl;
76 else
77 std::cout << " Name:" << lpName << std::endl;
78 EnumResourceLanguages(hModule, lpType, lpName, (ENUMRESLANGPROC)EnumLangsFunc, 0);
79 return TRUE;
80}
81
82BOOL EnumTypesFunc(HMODULE hModule, LPTSTR lpType, LONG lParam)
83{
84 if (IS_INTRESOURCE(lpType)) {
85 USHORT us = (USHORT)lpType;
86 if (us < 25)
87 std::cout << resource_type_name(us) << std::endl;
88 else
89 std::cout << us << std::endl;
90 }
91 else
92 std::cout << lpType << std::endl;
93 EnumResourceNames(hModule, lpType, (ENUMRESNAMEPROC)EnumNamesFunc, 0);
94 return TRUE;
95}
96namespace cgv {
97 namespace os {
98
99 void enum_resources(const std::string& prog_name)
100 {
101 #ifdef UNICODE
102 HMODULE hi = GetModuleHandleA(prog_name.c_str());
103 #else
104 HMODULE hi = GetModuleHandle(prog_name.c_str());
105 #endif
106 EnumResourceTypes(hi, (ENUMRESTYPEPROC)EnumTypesFunc, 0);
107 }
108 }
109}
110#else
111namespace cgv {
112 namespace os {
113
114 void enum_resources(const std::string& prog_name)
115 {
116 std::cout << "cgv::os::enum_resources() not implemented" << std::endl;
117 }
118 }
119}
120#endif
the cgv namespace
Definition print.h:11