FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
registrymap.hpp
Go to the documentation of this file.
1 
8 #pragma once
9 #ifndef COMLIB_REGISTRYMAP_HPP
10 #define COMLIB_REGISTRYMAP_HPP
11 
12 #include <atlbase.h>
13 
14 struct _ATL_REGMAP_ENTRYKeeper : public _ATL_REGMAP_ENTRY
15 {
16  _ATL_REGMAP_ENTRYKeeper(){ szKey=NULL; szData=NULL;}
17  _ATL_REGMAP_ENTRYKeeper(LPCOLESTR key, LPCSTR cstrData)
18  {
19  USES_CONVERSION;
20  CA2W data(cstrData);
21  szKey=key;
22  LPOLESTR newData;
23  szData = LPCOLESTR(newData = new wchar_t[wcslen(data)+1]);
24  wcscpy_s(newData,wcslen(data) + 1,data);
25  }
26  _ATL_REGMAP_ENTRYKeeper(LPCOLESTR key, LPCOLESTR data)
27  {
28  szKey=key;
29  LPOLESTR newData;
30  szData = LPCOLESTR(newData = new wchar_t[wcslen(data)+1]);
31  wcscpy_s(newData,wcslen(data)+1,data);
32  }
33  _ATL_REGMAP_ENTRYKeeper(LPCOLESTR key, UINT resid)
34  {
35  static wchar_t Data[256];
36  USES_CONVERSION;
37 
38  szKey=key;
39  if( 0 == LoadStringW(_pModule->m_hInstResource, resid, Data, 255))
40  {
41  *Data = '\0';
42  }
43 
44  int length = wcslen(Data);
45 
46  szData = new wchar_t[length];
47  wcscpy_s(const_cast<wchar_t *>(szData), length, Data);
48  }
49 
50  _ATL_REGMAP_ENTRYKeeper(LPCOLESTR key, REFGUID guid)
51  {
52  szKey=key;
53  LPOLESTR newData;
54  szData = LPCOLESTR(newData = new wchar_t[40]);
55  if(szData!=NULL)
56  {
57  if(0==StringFromGUID2(guid, newData,40))
58  {
59  *newData=NULL;
60  }
61  }
62  }
63  ~_ATL_REGMAP_ENTRYKeeper()
64  {
65  delete [] (LPOLESTR)szData;
66  }
67 };
68 
69 #define BEGIN_REGMAP(x) static struct _ATL_REGMAP_ENTRY *_GetRegistryMap() { static const _ATL_REGMAP_ENTRYKeeper map[] = {
70 
71 #define REGMAP_ENTRY(x,y) _ATL_REGMAP_ENTRYKeeper(OLESTR(##x),y),
72 
73 #define REGMAP_UUID(x,clsid) _ATL_REGMAP_ENTRYKeeper(OLESTR(##x),clsid),
74 
75 #define END_REGMAP() _ATL_REGMAP_ENTRYKeeper() }; return (_ATL_REGMAP_ENTRY *)map;}
76 
77 #define DECLARE_REGISTRY_RESOURCEID_EX(x) static HRESULT WINAPI UpdateRegistry(BOOL bRegister) throw()\
78  {\
79  __if_exists(_Module) \
80  { \
81  return _Module.UpdateRegistryFromResource((UINT)x, bRegister, _GetRegistryMap() ); \
82  } \
83  __if_not_exists(_Module) \
84  { \
85  return ATL::_pAtlModule->UpdateRegistryFromResource((UINT)x, bRegister, _GetRegistryMap() ); \
86  } \
87  }
88 
89 
90 #endif /* COMLIB_REGISTRYMAP_HPP */