Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.0, 1.0.1, and 1.0.2

shellext: replace tabs with spaces

Changeset 63daccd1e59f

Parent bc05894f8216

by Adrian Buehlmann

Changes to 8 files · Browse files at 63daccd1e59f Showing diff from parent bc05894f8216 Diff from another changeset...

 
24
25
26
27
 
28
29
30
31
 
 
 
32
33
34
35
36
37
38
39
 
 
 
 
 
 
 
40
41
42
43
44
45
 
 
46
47
48
49
50
51
 
 
52
53
 
54
55
56
 
 
57
58
 
59
60
61
62
 
 
 
63
64
65
66
 
 
 
67
68
69
70
71
72
73
74
 
 
 
 
 
 
 
75
76
77
78
79
80
81
82
83
 
 
 
 
 
 
 
 
84
85
86
87
88
 
 
 
 
89
90
91
92
93
 
 
 
 
94
95
96
 
 
97
98
99
100
101
 
 
 
 
102
103
 
104
105
106
107
108
109
 
 
110
111
112
113
114
115
 
 
 
 
 
116
117
118
119
 
 
 
120
121
122
123
 
 
 
124
125
126
127
128
129
130
131
132
133
134
135
136
137
 
 
 
 
 
 
 
 
 
 
 
 
 
138
139
140
141
142
143
144
145
146
147
148
149
150
151
 
 
 
 
 
 
 
 
 
 
 
 
 
152
153
154
155
 
 
 
156
157
158
 
 
159
160
 
161
162
163
164
165
 
166
167
168
169
170
171
 
 
 
 
 
172
173
174
175
 
 
 
176
177
178
179
180
181
182
183
184
185
186
 
 
 
 
 
 
 
 
 
 
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
207
208
209
210
211
 
 
 
 
 
212
213
 
214
215
216
217
218
219
220
221
222
223
224
225
226
227
 
 
 
 
 
 
 
 
 
 
228
229
230
 
 
231
232
 
233
234
235
236
237
238
239
240
241
 
 
 
 
 
242
243
244
245
 
 
 
246
247
248
249
250
251
252
253
254
255
 
 
 
 
 
 
 
 
 
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
274
275
 
 
276
277
278
 
 
279
280
281
 
 
282
283
 
284
 
24
25
26
 
27
28
 
 
 
29
30
31
32
 
 
 
 
 
 
 
33
34
35
36
37
38
39
40
41
42
43
 
 
44
45
46
47
48
49
 
 
50
51
52
 
53
54
 
 
55
56
57
 
58
59
 
 
 
60
61
62
63
 
 
 
64
65
66
67
 
 
 
 
 
 
 
68
69
70
71
72
73
74
75
 
 
 
 
 
 
 
 
76
77
78
79
80
81
82
83
84
 
 
 
 
85
86
87
88
89
 
 
 
 
90
91
92
93
94
 
 
95
96
97
 
 
 
 
98
99
100
101
102
 
103
104
105
106
107
 
 
108
109
110
 
 
 
 
 
111
112
113
114
115
116
 
 
 
117
118
119
120
 
 
 
121
122
123
124
 
 
 
 
 
 
 
 
 
 
 
 
 
125
126
127
128
129
130
131
132
133
134
135
136
137
138
 
 
 
 
 
 
 
 
 
 
 
 
 
139
140
141
142
143
144
145
146
147
148
149
150
151
152
 
 
 
153
154
155
156
 
 
157
158
159
 
160
161
162
163
164
 
165
166
 
 
 
 
 
167
168
169
170
171
172
 
 
 
173
174
175
176
 
 
 
 
 
 
 
 
 
 
177
178
179
180
181
182
183
184
185
186
187
188
189
190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
 
 
 
 
 
207
208
209
210
211
212
 
213
214
215
216
217
 
 
 
 
 
 
 
 
 
 
218
219
220
221
222
223
224
225
226
227
228
 
 
229
230
231
 
232
233
234
235
236
 
 
 
 
 
237
238
239
240
241
242
 
 
 
243
244
245
246
 
 
 
 
 
 
 
 
 
247
248
249
250
251
252
253
254
255
256
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
 
 
274
275
276
 
 
277
278
279
 
 
280
281
282
 
283
284
@@ -24,261 +24,261 @@
 #include "registry.h"    IconBitmapUtils::IconBitmapUtils() - : hUxTheme(NULL) + : hUxTheme(NULL)  { - if (SysInfo::Instance().IsVistaOrLater()) - { - hUxTheme = LoadLibrary(_T("UXTHEME.DLL")); + if (SysInfo::Instance().IsVistaOrLater()) + { + hUxTheme = LoadLibrary(_T("UXTHEME.DLL"));   - if (hUxTheme) - { - pfnGetBufferedPaintBits = (FN_GetBufferedPaintBits)::GetProcAddress(hUxTheme, "GetBufferedPaintBits"); - pfnBeginBufferedPaint = (FN_BeginBufferedPaint)::GetProcAddress(hUxTheme, "BeginBufferedPaint"); - pfnEndBufferedPaint = (FN_EndBufferedPaint)::GetProcAddress(hUxTheme, "EndBufferedPaint"); - } - } + if (hUxTheme) + { + pfnGetBufferedPaintBits = (FN_GetBufferedPaintBits)::GetProcAddress(hUxTheme, "GetBufferedPaintBits"); + pfnBeginBufferedPaint = (FN_BeginBufferedPaint)::GetProcAddress(hUxTheme, "BeginBufferedPaint"); + pfnEndBufferedPaint = (FN_EndBufferedPaint)::GetProcAddress(hUxTheme, "EndBufferedPaint"); + } + }  }    IconBitmapUtils::~IconBitmapUtils()  { - if (hUxTheme) - FreeLibrary(hUxTheme); + if (hUxTheme) + FreeLibrary(hUxTheme);  }    HBITMAP IconBitmapUtils::IconToBitmap(HICON hIcon)  { - if (!hIcon) - return NULL; + if (!hIcon) + return NULL;   - RECT rect; + RECT rect;   - rect.right = ::GetSystemMetrics(SM_CXMENUCHECK); - rect.bottom = ::GetSystemMetrics(SM_CYMENUCHECK); + rect.right = ::GetSystemMetrics(SM_CXMENUCHECK); + rect.bottom = ::GetSystemMetrics(SM_CYMENUCHECK);   - rect.left = rect.top = 0; + rect.left = rect.top = 0;   - HWND desktop = ::GetDesktopWindow(); - if (desktop == NULL) - return NULL; + HWND desktop = ::GetDesktopWindow(); + if (desktop == NULL) + return NULL;   - HDC screen_dev = ::GetDC(desktop); - if (screen_dev == NULL) - return NULL; + HDC screen_dev = ::GetDC(desktop); + if (screen_dev == NULL) + return NULL;   - // Create a compatible DC - HDC dst_hdc = ::CreateCompatibleDC(screen_dev); - if (dst_hdc == NULL) - { - ::ReleaseDC(desktop, screen_dev); - return NULL; - } + // Create a compatible DC + HDC dst_hdc = ::CreateCompatibleDC(screen_dev); + if (dst_hdc == NULL) + { + ::ReleaseDC(desktop, screen_dev); + return NULL; + }   - // Create a new bitmap of icon size - HBITMAP bmp = ::CreateCompatibleBitmap(screen_dev, rect.right, rect.bottom); - if (bmp == NULL) - { - ::DeleteDC(dst_hdc); - ::ReleaseDC(desktop, screen_dev); - return NULL; - } + // Create a new bitmap of icon size + HBITMAP bmp = ::CreateCompatibleBitmap(screen_dev, rect.right, rect.bottom); + if (bmp == NULL) + { + ::DeleteDC(dst_hdc); + ::ReleaseDC(desktop, screen_dev); + return NULL; + }   - // Select it into the compatible DC - HBITMAP old_dst_bmp = (HBITMAP)::SelectObject(dst_hdc, bmp); - if (old_dst_bmp == NULL) - return NULL; + // Select it into the compatible DC + HBITMAP old_dst_bmp = (HBITMAP)::SelectObject(dst_hdc, bmp); + if (old_dst_bmp == NULL) + return NULL;   - // Fill the background of the compatible DC with the white color - // that is taken by menu routines as transparent - ::SetBkColor(dst_hdc, RGB(255, 255, 255)); - ::ExtTextOut(dst_hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL); + // Fill the background of the compatible DC with the white color + // that is taken by menu routines as transparent + ::SetBkColor(dst_hdc, RGB(255, 255, 255)); + ::ExtTextOut(dst_hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);   - // Draw the icon into the compatible DC - ::DrawIconEx(dst_hdc, 0, 0, hIcon, rect.right, rect.bottom, 0, NULL, DI_NORMAL); + // Draw the icon into the compatible DC + ::DrawIconEx(dst_hdc, 0, 0, hIcon, rect.right, rect.bottom, 0, NULL, DI_NORMAL);   - // Restore settings - ::SelectObject(dst_hdc, old_dst_bmp); - ::DeleteDC(dst_hdc); - ::ReleaseDC(desktop, screen_dev); + // Restore settings + ::SelectObject(dst_hdc, old_dst_bmp); + ::DeleteDC(dst_hdc); + ::ReleaseDC(desktop, screen_dev);   - return bmp; + return bmp;  }    HBITMAP IconBitmapUtils::IconToBitmapPARGB32(HICON hIcon)  { - if (!hIcon) - return NULL; + if (!hIcon) + return NULL;   - if (pfnBeginBufferedPaint == NULL || pfnEndBufferedPaint == NULL || pfnGetBufferedPaintBits == NULL) - { - TDEBUG_TRACE(" IconBitmapUtils::IconToBitmapPARGB32: Theme functions not found, returns NULL"); - return NULL; - } + if (pfnBeginBufferedPaint == NULL || pfnEndBufferedPaint == NULL || pfnGetBufferedPaintBits == NULL) + { + TDEBUG_TRACE(" IconBitmapUtils::IconToBitmapPARGB32: Theme functions not found, returns NULL"); + return NULL; + }   - SIZE sizIcon; - sizIcon.cx = GetSystemMetrics(SM_CXSMICON); - sizIcon.cy = GetSystemMetrics(SM_CYSMICON); + SIZE sizIcon; + sizIcon.cx = GetSystemMetrics(SM_CXSMICON); + sizIcon.cy = GetSystemMetrics(SM_CYSMICON);   - RECT rcIcon; - SetRect(&rcIcon, 0, 0, sizIcon.cx, sizIcon.cy); - HBITMAP hBmp = NULL; + RECT rcIcon; + SetRect(&rcIcon, 0, 0, sizIcon.cx, sizIcon.cy); + HBITMAP hBmp = NULL;   - HDC hdcDest = CreateCompatibleDC(NULL); - if (hdcDest) - { - if (SUCCEEDED(Create32BitHBITMAP(hdcDest, &sizIcon, NULL, &hBmp))) - { - HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcDest, hBmp); - if (hbmpOld) - { - BLENDFUNCTION bfAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; - BP_PAINTPARAMS paintParams = {0}; - paintParams.cbSize = sizeof(paintParams); - paintParams.dwFlags = BPPF_ERASE; - paintParams.pBlendFunction = &bfAlpha; + HDC hdcDest = CreateCompatibleDC(NULL); + if (hdcDest) + { + if (SUCCEEDED(Create32BitHBITMAP(hdcDest, &sizIcon, NULL, &hBmp))) + { + HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcDest, hBmp); + if (hbmpOld) + { + BLENDFUNCTION bfAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; + BP_PAINTPARAMS paintParams = {0}; + paintParams.cbSize = sizeof(paintParams); + paintParams.dwFlags = BPPF_ERASE; + paintParams.pBlendFunction = &bfAlpha;   - HDC hdcBuffer; - HPAINTBUFFER hPaintBuffer = pfnBeginBufferedPaint(hdcDest, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer); - if (hPaintBuffer) - { - if (DrawIconEx(hdcBuffer, 0, 0, hIcon, sizIcon.cx, sizIcon.cy, 0, NULL, DI_NORMAL)) - //if (FillRect(hdcBuffer, &rcIcon, (HBRUSH) (0x000000FF)) != 0) - { - // If icon did not have an alpha channel we need to convert buffer to PARGB - ConvertBufferToPARGB32(hPaintBuffer, hdcDest, hIcon, sizIcon); - } - // This will write the buffer contents to the destination bitmap - pfnEndBufferedPaint(hPaintBuffer, TRUE); - } + HDC hdcBuffer; + HPAINTBUFFER hPaintBuffer = pfnBeginBufferedPaint(hdcDest, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer); + if (hPaintBuffer) + { + if (DrawIconEx(hdcBuffer, 0, 0, hIcon, sizIcon.cx, sizIcon.cy, 0, NULL, DI_NORMAL)) + //if (FillRect(hdcBuffer, &rcIcon, (HBRUSH) (0x000000FF)) != 0) + { + // If icon did not have an alpha channel we need to convert buffer to PARGB + ConvertBufferToPARGB32(hPaintBuffer, hdcDest, hIcon, sizIcon); + } + // This will write the buffer contents to the destination bitmap + pfnEndBufferedPaint(hPaintBuffer, TRUE); + }   - SelectObject(hdcDest, hbmpOld); - } - } + SelectObject(hdcDest, hbmpOld); + } + }   - DeleteDC(hdcDest); - } + DeleteDC(hdcDest); + }   - return hBmp; + return hBmp;  }    HRESULT IconBitmapUtils::Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp)  { - *phBmp = NULL; + *phBmp = NULL;   - BITMAPINFO bmi; - SecureZeroMemory(&bmi, sizeof(bmi)); - bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biCompression = BI_RGB; + BITMAPINFO bmi; + SecureZeroMemory(&bmi, sizeof(bmi)); + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biCompression = BI_RGB;   - bmi.bmiHeader.biWidth = psize->cx; - bmi.bmiHeader.biHeight = psize->cy; - bmi.bmiHeader.biBitCount = 32; + bmi.bmiHeader.biWidth = psize->cx; + bmi.bmiHeader.biHeight = psize->cy; + bmi.bmiHeader.biBitCount = 32;   - HDC hdcUsed = hdc ? hdc : GetDC(NULL); - if (hdcUsed) - { - *phBmp = CreateDIBSection(hdcUsed, &bmi, DIB_RGB_COLORS, ppvBits, NULL, 0); - if (hdc != hdcUsed) - { - ReleaseDC(NULL, hdcUsed); - } - } - return (NULL == *phBmp) ? E_OUTOFMEMORY : S_OK; + HDC hdcUsed = hdc ? hdc : GetDC(NULL); + if (hdcUsed) + { + *phBmp = CreateDIBSection(hdcUsed, &bmi, DIB_RGB_COLORS, ppvBits, NULL, 0); + if (hdc != hdcUsed) + { + ReleaseDC(NULL, hdcUsed); + } + } + return (NULL == *phBmp) ? E_OUTOFMEMORY : S_OK;  }    HRESULT IconBitmapUtils::ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon)  { - RGBQUAD *prgbQuad; - int cxRow; - HRESULT hr = pfnGetBufferedPaintBits(hPaintBuffer, &prgbQuad, &cxRow); - if (SUCCEEDED(hr)) - { - Gdiplus::ARGB *pargb = reinterpret_cast<Gdiplus::ARGB *>(prgbQuad); - if (!HasAlpha(pargb, sizIcon, cxRow)) - { - ICONINFO info; - if (GetIconInfo(hicon, &info)) - { - if (info.hbmMask) - { - hr = ConvertToPARGB32(hdc, pargb, info.hbmMask, sizIcon, cxRow); - } + RGBQUAD *prgbQuad; + int cxRow; + HRESULT hr = pfnGetBufferedPaintBits(hPaintBuffer, &prgbQuad, &cxRow); + if (SUCCEEDED(hr)) + { + Gdiplus::ARGB *pargb = reinterpret_cast<Gdiplus::ARGB *>(prgbQuad); + if (!HasAlpha(pargb, sizIcon, cxRow)) + { + ICONINFO info; + if (GetIconInfo(hicon, &info)) + { + if (info.hbmMask) + { + hr = ConvertToPARGB32(hdc, pargb, info.hbmMask, sizIcon, cxRow); + }   - DeleteObject(info.hbmColor); - DeleteObject(info.hbmMask); - } - } - } + DeleteObject(info.hbmColor); + DeleteObject(info.hbmMask); + } + } + }   - return hr; + return hr;  }    bool IconBitmapUtils::HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow)  { - ULONG cxDelta = cxRow - sizImage.cx; - for (ULONG y = sizImage.cy; y; --y) - { - for (ULONG x = sizImage.cx; x; --x) - { - if (*pargb++ & 0xFF000000) - { - return true; - } - } + ULONG cxDelta = cxRow - sizImage.cx; + for (ULONG y = sizImage.cy; y; --y) + { + for (ULONG x = sizImage.cx; x; --x) + { + if (*pargb++ & 0xFF000000) + { + return true; + } + }   - pargb += cxDelta; - } + pargb += cxDelta; + }   - return false; + return false;  }    HRESULT IconBitmapUtils::ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow)  { - BITMAPINFO bmi; - SecureZeroMemory(&bmi, sizeof(bmi)); - bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biCompression = BI_RGB; + BITMAPINFO bmi; + SecureZeroMemory(&bmi, sizeof(bmi)); + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biCompression = BI_RGB;   - bmi.bmiHeader.biWidth = sizImage.cx; - bmi.bmiHeader.biHeight = sizImage.cy; - bmi.bmiHeader.biBitCount = 32; + bmi.bmiHeader.biWidth = sizImage.cx; + bmi.bmiHeader.biHeight = sizImage.cy; + bmi.bmiHeader.biBitCount = 32;   - HRESULT hr = E_OUTOFMEMORY; - HANDLE hHeap = GetProcessHeap(); - void *pvBits = HeapAlloc(hHeap, 0, bmi.bmiHeader.biWidth * 4 * bmi.bmiHeader.biHeight); - if (pvBits) - { - hr = E_UNEXPECTED; - if (GetDIBits(hdc, hbmp, 0, bmi.bmiHeader.biHeight, pvBits, &bmi, DIB_RGB_COLORS) == bmi.bmiHeader.biHeight) - { - ULONG cxDelta = cxRow - bmi.bmiHeader.biWidth; + HRESULT hr = E_OUTOFMEMORY; + HANDLE hHeap = GetProcessHeap(); + void *pvBits = HeapAlloc(hHeap, 0, bmi.bmiHeader.biWidth * 4 * bmi.bmiHeader.biHeight); + if (pvBits) + { + hr = E_UNEXPECTED; + if (GetDIBits(hdc, hbmp, 0, bmi.bmiHeader.biHeight, pvBits, &bmi, DIB_RGB_COLORS) == bmi.bmiHeader.biHeight) + { + ULONG cxDelta = cxRow - bmi.bmiHeader.biWidth;   Gdiplus::ARGB *pargbMask = static_cast<Gdiplus::ARGB *>(pvBits);   - for (ULONG y = bmi.bmiHeader.biHeight; y; --y) - { - for (ULONG x = bmi.bmiHeader.biWidth; x; --x) - { - if (*pargbMask++) - { - // transparent pixel - *pargb++ = 0; - } - else - { - // opaque pixel - *pargb++ |= 0xFF000000; - } - } + for (ULONG y = bmi.bmiHeader.biHeight; y; --y) + { + for (ULONG x = bmi.bmiHeader.biWidth; x; --x) + { + if (*pargbMask++) + { + // transparent pixel + *pargb++ = 0; + } + else + { + // opaque pixel + *pargb++ |= 0xFF000000; + } + }   - pargb += cxDelta; - } + pargb += cxDelta; + }   - hr = S_OK; - } + hr = S_OK; + }   - HeapFree(hHeap, 0, pvBits); - } + HeapFree(hHeap, 0, pvBits); + }   - return hr; + return hr;  }
 
36
37
38
39
40
 
 
41
42
43
44
45
46
47
 
 
 
 
 
 
48
49
50
51
 
52
53
54
55
 
 
 
56
 
36
37
38
 
 
39
40
41
 
 
 
 
 
 
42
43
44
45
46
47
48
49
50
 
51
52
 
 
 
53
54
55
56
@@ -36,21 +36,21 @@
 class IconBitmapUtils  {  public: - IconBitmapUtils(void); - ~IconBitmapUtils(void); + IconBitmapUtils(void); + ~IconBitmapUtils(void);   - HBITMAP IconToBitmap(HICON hIcon); - HBITMAP IconToBitmapPARGB32(HICON hIcon); - HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp); - HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon); - bool HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow); - HRESULT ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow); + HBITMAP IconToBitmap(HICON hIcon); + HBITMAP IconToBitmapPARGB32(HICON hIcon); + HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp); + HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon); + bool HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow); + HRESULT ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow);      private: - HMODULE hUxTheme; + HMODULE hUxTheme;   - FN_GetBufferedPaintBits pfnGetBufferedPaintBits; - FN_BeginBufferedPaint pfnBeginBufferedPaint; - FN_EndBufferedPaint pfnEndBufferedPaint; + FN_GetBufferedPaintBits pfnGetBufferedPaintBits; + FN_BeginBufferedPaint pfnBeginBufferedPaint; + FN_EndBufferedPaint pfnEndBufferedPaint;  };
 
29
30
31
32
33
34
35
36
37
 
 
 
 
 
 
38
39
40
 
66
67
68
69
 
70
71
72
73
74
75
76
 
 
 
77
78
79
80
81
82
 
 
83
84
85
86
87
88
 
89
90
91
 
101
102
103
104
 
105
106
107
108
109
110
111
 
 
 
112
113
114
115
116
117
 
 
118
119
120
121
122
123
 
124
125
126
 
129
130
131
132
133
134
135
136
 
 
 
 
 
137
138
139
140
141
142
 
 
143
144
145
146
147
148
149
150
151
152
153
 
 
 
 
 
 
 
154
155
156
157
158
159
 
 
160
161
162
163
164
 
165
166
167
168
169
170
171
172
173
174
175
176
177
178
 
 
 
 
 
 
 
 
 
 
 
 
 
179
180
 
181
182
183
184
185
 
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
202
 
203
204
205
 
29
30
31
 
 
 
 
 
 
32
33
34
35
36
37
38
39
40
 
66
67
68
 
69
70
71
72
73
 
 
 
74
75
76
77
78
79
80
 
 
81
82
83
84
85
86
87
 
88
89
90
91
 
101
102
103
 
104
105
106
107
108
 
 
 
109
110
111
112
113
114
115
 
 
116
117
118
119
120
121
122
 
123
124
125
126
 
129
130
131
 
 
 
 
 
132
133
134
135
136
137
138
139
140
 
 
141
142
143
144
145
146
 
 
 
 
 
 
 
147
148
149
150
151
152
153
154
155
156
157
 
 
158
159
160
161
162
163
 
164
165
 
 
 
 
 
 
 
 
 
 
 
 
 
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
180
181
182
183
184
 
185
186
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
 
202
203
204
205
@@ -29,12 +29,12 @@
 CRegBase::CRegBase (const CString& key, bool force, HKEY base, REGSAM sam)   : CRegBaseCommon<CString> (key, force, base, sam)  { - m_key.TrimLeft(_T("\\")); - int backslashpos = m_key.ReverseFind('\\'); - m_path = m_key.Left(backslashpos); - m_path.TrimRight(_T("\\")); - m_key = m_key.Mid(backslashpos); - m_key.Trim(_T("\\")); + m_key.TrimLeft(_T("\\")); + int backslashpos = m_key.ReverseFind('\\'); + m_path = m_key.Left(backslashpos); + m_path.TrimRight(_T("\\")); + m_key = m_key.Mid(backslashpos); + m_key.Trim(_T("\\"));  }  #endif   @@ -66,26 +66,26 @@
 CRegRect::CRegRect(const CString& key, const CRect& def, bool force, HKEY base, REGSAM sam)   : CRegTypedBase<CRect, CRegBase> (key, def, force, base, sam)  { - read(); + read();  }    void CRegRect::InternalRead (HKEY hKey, CRect& value)  { - DWORD size = 0; - DWORD type = 0; - RegQueryValueEx(hKey, m_key, NULL, &type, NULL, (LPDWORD) &size); + DWORD size = 0; + DWORD type = 0; + RegQueryValueEx(hKey, m_key, NULL, &type, NULL, (LPDWORD) &size);     auto_buffer<char> buffer (size);   if ((LastError = RegQueryValueEx(hKey, m_key, NULL, &type, (BYTE*) buffer.get(), &size))==ERROR_SUCCESS)   { - ASSERT(type==REG_BINARY); - value = CRect((LPRECT)buffer.get()); + ASSERT(type==REG_BINARY); + value = CRect((LPRECT)buffer.get());   }  }    void CRegRect::InternalWrite (HKEY hKey, const CRect& value)  { - LastError = RegSetValueEx(hKey, m_key, 0, REG_BINARY, (BYTE *)(LPCRECT)value, sizeof(value)); + LastError = RegSetValueEx(hKey, m_key, 0, REG_BINARY, (BYTE *)(LPCRECT)value, sizeof(value));  }    #endif @@ -101,26 +101,26 @@
 CRegPoint::CRegPoint(const CString& key, const CPoint& def, bool force, HKEY base, REGSAM sam)   : CRegTypedBase<CPoint, CRegBase> (key, def, force, base, sam)  { - read(); + read();  }    void CRegPoint::InternalRead (HKEY hKey, CPoint& value)  { - DWORD size = 0; - DWORD type = 0; - RegQueryValueEx(hKey, m_key, NULL, &type, NULL, (LPDWORD) &size); + DWORD size = 0; + DWORD type = 0; + RegQueryValueEx(hKey, m_key, NULL, &type, NULL, (LPDWORD) &size);     auto_buffer<char> buffer(size);   if ((LastError = RegQueryValueEx(hKey, m_key, NULL, &type, (BYTE*) buffer.get(), &size))==ERROR_SUCCESS)   { - ASSERT(type==REG_BINARY); - value = CPoint(*(POINT*)buffer.get()); + ASSERT(type==REG_BINARY); + value = CPoint(*(POINT*)buffer.get());   }  }    void CRegPoint::InternalWrite (HKEY hKey, const CPoint& value)  { - LastError = RegSetValueEx(hKey, m_key, 0, REG_BINARY, (BYTE *)&value, sizeof(value)); + LastError = RegSetValueEx(hKey, m_key, 0, REG_BINARY, (BYTE *)&value, sizeof(value));  }  #endif   @@ -129,77 +129,77 @@
 #ifdef __AFXCOLL_H__ // defines CStringList  CRegistryKey::CRegistryKey(const CString& key, HKEY base, REGSAM sam)  { - m_base = base; - m_hKey = NULL; - m_sam = sam; - m_path = key; - m_path.TrimLeft(_T("\\")); + m_base = base; + m_hKey = NULL; + m_sam = sam; + m_path = key; + m_path.TrimLeft(_T("\\"));  }    CRegistryKey::~CRegistryKey()  { - if (m_hKey) - RegCloseKey(m_hKey); + if (m_hKey) + RegCloseKey(m_hKey);  }    DWORD CRegistryKey::createKey()  { - DWORD disp; - DWORD rc = RegCreateKeyEx(m_base, m_path, 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_WRITE|m_sam, NULL, &m_hKey, &disp); - if (rc != ERROR_SUCCESS) - { - return rc; - } - return RegCloseKey(m_hKey); + DWORD disp; + DWORD rc = RegCreateKeyEx(m_base, m_path, 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_WRITE|m_sam, NULL, &m_hKey, &disp); + if (rc != ERROR_SUCCESS) + { + return rc; + } + return RegCloseKey(m_hKey);  }    DWORD CRegistryKey::removeKey()  { - RegOpenKeyEx(m_base, m_path, 0, KEY_WRITE|m_sam, &m_hKey); - return SHDeleteKey(m_base, (LPCTSTR)m_path); + RegOpenKeyEx(m_base, m_path, 0, KEY_WRITE|m_sam, &m_hKey); + return SHDeleteKey(m_base, (LPCTSTR)m_path);  }    bool CRegistryKey::getValues(CStringList& values)  { - values.RemoveAll(); + values.RemoveAll();   - if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS) - { - for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++) - { - TCHAR value[255]; - DWORD size = sizeof value / sizeof TCHAR; - rc = RegEnumValue(m_hKey, i, value, &size, NULL, NULL, NULL, NULL); - if (rc == ERROR_SUCCESS) - { - values.AddTail(value); - } - } - } + if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS) + { + for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++) + { + TCHAR value[255]; + DWORD size = sizeof value / sizeof TCHAR; + rc = RegEnumValue(m_hKey, i, value, &size, NULL, NULL, NULL, NULL); + if (rc == ERROR_SUCCESS) + { + values.AddTail(value); + } + } + }   - return values.GetCount() > 0; + return values.GetCount() > 0;  }    bool CRegistryKey::getSubKeys(CStringList& subkeys)  { - subkeys.RemoveAll(); + subkeys.RemoveAll();   - if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS) - { - for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++) - { - TCHAR value[1024]; - DWORD size = sizeof value / sizeof TCHAR; - FILETIME last_write_time; - rc = RegEnumKeyEx(m_hKey, i, value, &size, NULL, NULL, NULL, &last_write_time); - if (rc == ERROR_SUCCESS) - { - subkeys.AddTail(value); - } - } - } + if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS) + { + for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++) + { + TCHAR value[1024]; + DWORD size = sizeof value / sizeof TCHAR; + FILETIME last_write_time; + rc = RegEnumKeyEx(m_hKey, i, value, &size, NULL, NULL, NULL, &last_write_time); + if (rc == ERROR_SUCCESS) + { + subkeys.AddTail(value); + } + } + }   - return subkeys.GetCount() > 0; + return subkeys.GetCount() > 0;  }  #endif  
 
21
22
23
24
25
26
 
 
 
27
28
29
 
32
33
34
35
36
 
 
37
38
39
40
 
21
22
23
 
 
 
24
25
26
27
28
29
 
32
33
34
 
 
35
36
37
38
 
 
@@ -21,9 +21,9 @@
   SysInfo::SysInfo(void)  { - SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX)); - inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - GetVersionEx((OSVERSIONINFO *)&inf); + SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX)); + inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + GetVersionEx((OSVERSIONINFO *)&inf);  }    SysInfo::~SysInfo(void) @@ -32,9 +32,7 @@
   const SysInfo& SysInfo::Instance()  { - static SysInfo instance; - return instance; + static SysInfo instance; + return instance;  }   - -
 
26
27
28
29
30
 
 
31
32
33
34
35
36
37
38
39
 
 
 
 
 
 
 
 
40
41
 
42
 
26
27
28
 
 
29
30
31
 
 
 
 
 
 
 
 
32
33
34
35
36
37
38
39
40
 
41
42
@@ -26,17 +26,17 @@
 class SysInfo  {  private: - SysInfo(void); - ~SysInfo(void); + SysInfo(void); + ~SysInfo(void);  public: - static const SysInfo& Instance(); - - DWORD GetFullVersion() const {return MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);} - bool IsXP() const {return (GetFullVersion() < 0x0600);} // cover Win5.1 and 5.2 alike - bool IsVista() const {return (GetFullVersion() == 0x0600);} - bool IsVistaOrLater() const {return (GetFullVersion() >= 0x0600);} - bool IsWin7() const {return (GetFullVersion() == 0x0601);} - bool IsWin7OrLater() const {return (GetFullVersion() >= 0x0601);} + static const SysInfo& Instance(); + + DWORD GetFullVersion() const {return MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);} + bool IsXP() const {return (GetFullVersion() < 0x0600);} // cover Win5.1 and 5.2 alike + bool IsVista() const {return (GetFullVersion() == 0x0600);} + bool IsVistaOrLater() const {return (GetFullVersion() >= 0x0600);} + bool IsWin7() const {return (GetFullVersion() == 0x0601);} + bool IsWin7OrLater() const {return (GetFullVersion() >= 0x0601);}  private: - OSVERSIONINFOEX inf; + OSVERSIONINFOEX inf;  };
 
41
42
43
44
 
45
46
47
 
 
48
49
50
51
52
 
 
 
 
53
54
55
56
57
 
 
 
 
58
59
60
61
62
 
 
 
 
63
64
65
66
67
68
69
70
71
 
 
 
72
73
74
75
76
 
 
 
77
78
79
 
41
42
43
 
44
45
 
 
46
47
48
 
 
 
 
49
50
51
52
53
 
 
 
 
54
55
56
57
58
 
 
 
 
59
60
61
62
63
64
65
66
67
68
 
 
 
69
70
71
72
73
 
 
 
74
75
76
77
78
79
@@ -41,39 +41,39 @@
   public:   - explicit auto_buffer (size_t size = 0) throw() + explicit auto_buffer (size_t size = 0) throw()   : buffer (size == 0 ? NULL : new T[size]) - { - } + { + }   - ~auto_buffer() - { - delete[] buffer; - } + ~auto_buffer() + { + delete[] buffer; + }   - operator T*() const throw() - { - return buffer; - } + operator T*() const throw() + { + return buffer; + }   - operator void*() const throw() - { - return buffer; - } + operator void*() const throw() + { + return buffer; + }     operator bool() const throw()   {   return buffer != NULL;   }   - T* operator->() const throw() - { - return buffer; + T* operator->() const throw() + { + return buffer;   }   - T *get() const throw() - { - return buffer; + T *get() const throw() + { + return buffer;   }     T* release() throw()
 
53
54
55
56
57
58
59
60
61
62
 
 
 
 
 
 
 
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
79
80
81
82
83
84
 
 
 
 
 
 
85
86
87
88
89
90
91
92
93
94
 
 
 
 
 
 
 
 
 
95
96
97
 
 
98
99
100
 
107
108
109
110
 
111
112
113
114
115
116
117
 
 
 
 
 
118
119
120
 
 
121
122
123
 
129
130
131
132
 
133
134
135
 
139
140
141
142
 
143
144
145
 
146
147
148
 
193
194
195
196
197
198
199
200
201
202
 
 
 
 
 
 
 
203
204
205
206
207
208
 
 
 
 
 
209
210
211
212
213
 
 
 
214
215
 
216
217
 
218
219
220
 
241
242
243
244
245
246
247
248
249
250
 
 
 
 
 
 
 
251
252
253
 
269
270
271
272
273
274
 
 
 
275
276
277
 
293
294
295
296
297
 
 
298
299
300
 
334
335
336
337
 
338
339
340
341
 
342
343
344
345
346
347
348
349
 
 
 
 
 
 
 
350
351
352
353
354
355
356
357
358
359
 
 
 
 
 
 
 
 
360
361
362
363
364
365
366
367
368
 
 
 
 
 
 
 
369
370
371
 
375
376
377
378
 
379
380
381
 
426
427
428
429
 
430
431
432
433
434
435
 
 
 
436
437
438
439
440
441
 
 
442
443
444
 
 
445
446
447
 
448
449
450
 
455
456
457
458
459
460
461
 
 
 
 
462
463
464
465
466
 
 
 
467
468
469
 
 
470
471
472
 
490
491
492
493
494
495
496
497
498
499
500
 
 
 
 
 
 
 
 
501
502
 
503
504
505
506
507
508
509
510
511
512
513
514
515
516
 
 
 
 
 
 
 
 
 
517
518
519
 
535
536
537
538
539
540
 
 
 
541
542
543
 
568
569
570
571
572
573
574
575
576
577
578
 
 
 
 
 
 
 
 
579
580
581
582
583
584
585
586
587
588
589
590
591
592
 
 
 
 
 
 
 
 
 
 
593
594
595
 
616
617
618
619
620
 
 
621
622
 
623
624
625
626
627
628
629
 
630
631
632
 
648
649
650
651
652
 
 
653
654
655
 
688
689
690
691
692
693
694
695
696
697
698
 
 
 
 
 
 
 
 
699
700
701
 
702
703
 
704
705
706
 
726
727
728
729
730
731
 
 
 
732
733
734
 
735
736
737
 
741
742
743
744
 
745
746
747
 
763
764
765
766
 
767
768
769
 
805
806
807
808
809
810
811
812
813
814
815
816
817
818
 
 
 
 
 
 
 
 
 
 
 
819
820
821
822
823
824
825
826
827
828
829
830
 
 
 
 
 
 
 
 
 
 
 
831
832
833
 
850
851
852
853
 
854
855
856
 
891
892
893
894
895
896
897
898
899
900
901
902
903
904
 
 
 
 
 
 
 
 
 
 
 
905
906
907
 
 
908
909
910
 
918
919
920
921
922
923
924
925
926
927
 
 
 
 
 
 
 
928
929
930
931
932
933
934
935
936
937
938
939
940
 
 
 
 
 
 
 
 
 
 
 
 
941
942
943
 
 
944
945
946
947
948
949
 
 
 
 
 
950
951
952
 
53
54
55
 
 
 
 
 
 
 
56
57
58
59
60
61
62
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 
 
 
 
 
 
79
80
81
82
83
84
85
 
 
 
 
 
 
 
 
 
86
87
88
89
90
91
92
93
94
95
 
 
96
97
98
99
100
 
107
108
109
 
110
111
112
 
 
 
 
 
113
114
115
116
117
118
 
 
119
120
121
122
123
 
129
130
131
 
132
133
134
135
 
139
140
141
 
142
143
144
 
145
146
147
148
 
193
194
195
 
 
 
 
 
 
 
196
197
198
199
200
201
202
203
 
 
 
 
 
204
205
206
207
208
209
210
 
 
 
211
212
213
214
 
215
216
 
217
218
219
220
 
241
242
243
 
 
 
 
 
 
 
244
245
246
247
248
249
250
251
252
253
 
269
270
271
 
 
 
272
273
274
275
276
277
 
293
294
295
 
 
296
297
298
299
300
 
334
335
336
 
337
338
339
340
 
341
342
 
 
 
 
 
 
 
343
344
345
346
347
348
349
350
351
 
 
 
 
 
 
 
 
352
353
354
355
356
357
358
359
360
361
 
 
 
 
 
 
 
362
363
364
365
366
367
368
369
370
371
 
375
376
377
 
378
379
380
381
 
426
427
428
 
429
430
431
432
 
 
 
433
434
435
436
437
438
439
 
 
440
441
442
 
 
443
444
445
446
 
447
448
449
450
 
455
456
457
 
 
 
 
458
459
460
461
462
463
 
 
 
464
465
466
467
 
 
468
469
470
471
472
 
490
491
492
 
 
 
 
 
 
 
 
493
494
495
496
497
498
499
500
501
 
502
503
504
505
506
507
 
 
 
 
 
 
 
 
 
508
509
510
511
512
513
514
515
516
517
518
519
 
535
536
537
 
 
 
538
539
540
541
542
543
 
568
569
570
 
 
 
 
 
 
 
 
571
572
573
574
575
576
577
578
579
580
581
582
 
 
 
 
 
 
 
 
 
 
583
584
585
586
587
588
589
590
591
592
593
594
595
 
616
617
618
 
 
619
620
621
 
622
623
624
625
626
627
628
 
629
630
631
632
 
648
649
650
 
 
651
652
653
654
655
 
688
689
690
 
 
 
 
 
 
 
 
691
692
693
694
695
696
697
698
699
700
 
701
702
 
703
704
705
706
 
726
727
728
 
 
 
729
730
731
732
733
 
734
735
736
737
 
741
742
743
 
744
745
746
747
 
763
764
765
 
766
767
768
769
 
805
806
807
 
 
 
 
 
 
 
 
 
 
 
808
809
810
811
812
813
814
815
816
817
818
819
 
 
 
 
 
 
 
 
 
 
 
820
821
822
823
824
825
826
827
828
829
830
831
832
833
 
850
851
852
 
853
854
855
856
 
891
892
893
 
 
 
 
 
 
 
 
 
 
 
894
895
896
897
898
899
900
901
902
903
904
905
 
 
906
907
908
909
910
 
918
919
920
 
 
 
 
 
 
 
921
922
923
924
925
926
927
928
 
 
 
 
 
 
 
 
 
 
 
 
929
930
931
932
933
934
935
936
937
938
939
940
941
 
 
942
943
944
 
 
 
 
 
945
946
947
948
949
950
951
952
@@ -53,48 +53,48 @@
  /** Default constructor.   */   CRegBaseCommon(); - /** - * Constructor. - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" - * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ - CRegBaseCommon(const S& key, bool force, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); + /** + * Constructor. + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" + * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */ + CRegBaseCommon(const S& key, bool force, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0);   - /** - * Removes the whole registry key including all values. So if you set the registry - * entry to be HKCU\Software\Company\Product\key\value there will only be - * HKCU\Software\Company\Product key in the registry. - * \return ERROR_SUCCESS or an nonzero error code. Use FormatMessage() to get an error description. - */ - DWORD removeKey(); - /** - * Removes the value of the registry object. If you set the registry entry to - * be HKCU\Software\Company\Product\key\value there will only be - * HKCU\Software\Company\Product\key\ in the registry. - * \return ERROR_SUCCESS or an nonzero error code. Use FormatMessage() to get an error description. - */ - LONG removeValue(); + /** + * Removes the whole registry key including all values. So if you set the registry + * entry to be HKCU\Software\Company\Product\key\value there will only be + * HKCU\Software\Company\Product key in the registry. + * \return ERROR_SUCCESS or an nonzero error code. Use FormatMessage() to get an error description. + */ + DWORD removeKey(); + /** + * Removes the value of the registry object. If you set the registry entry to + * be HKCU\Software\Company\Product\key\value there will only be + * HKCU\Software\Company\Product\key\ in the registry. + * \return ERROR_SUCCESS or an nonzero error code. Use FormatMessage() to get an error description. + */ + LONG removeValue();   - /** - * Returns the string of the last error occurred. - */ - virtual S getErrorString() - { - LPVOID lpMsgBuf; + /** + * Returns the string of the last error occurred. + */ + virtual S getErrorString() + { + LPVOID lpMsgBuf;   - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - LastError, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &lpMsgBuf, - 0, NULL ); + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + LastError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &lpMsgBuf, + 0, NULL );   - return (LPCTSTR)lpMsgBuf; - }; + return (LPCTSTR)lpMsgBuf; + };     /// get failure info for last operation   @@ -107,17 +107,17 @@
    typedef S StringT;   -protected: +protected:     //members - HKEY m_base; ///< handle to the registry base - S m_key; ///< the name of the value - S m_path; ///< the path to the key - LONG LastError; ///< the value of the last error occurred - REGSAM m_sam; ///< the security attributes to pass to the registry command + HKEY m_base; ///< handle to the registry base + S m_key; ///< the name of the value + S m_path; ///< the path to the key + LONG LastError; ///< the value of the last error occurred + REGSAM m_sam; ///< the security attributes to pass to the registry command   - bool m_read; ///< indicates if the value has already been read from the registry - bool m_force; ///< indicates if no cache should be used, i.e. always read and write directly from registry + bool m_read; ///< indicates if the value has already been read from the registry + bool m_force; ///< indicates if no cache should be used, i.e. always read and write directly from registry   bool m_exists; ///< true, if the registry actually exists  };   @@ -129,7 +129,7 @@
  , m_key()   , m_path()   , LastError (ERROR_SUCCESS) - , m_sam (0) + , m_sam (0)   , m_read (false)   , m_force (false)   , m_exists (false) @@ -139,10 +139,10 @@
 template<class S>  CRegBaseCommon<S>::CRegBaseCommon (const S& key, bool force, HKEY base, REGSAM sam)   : m_base (base) - , m_key (key) + , m_key (key)   , m_path()   , LastError (ERROR_SUCCESS) - , m_sam (sam) + , m_sam (sam)   , m_read (false)   , m_force (force)   , m_exists (false) @@ -193,28 +193,28 @@
  /** Default constructor.   */   CRegBase(); - /** - * Constructor. - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" - * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ - CRegBase(const CString& key, bool force, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); + /** + * Constructor. + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" + * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */ + CRegBase(const CString& key, bool force, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0);   - /** - * Returns the string of the last error occurred. - */ - CString getErrorString() - { + /** + * Returns the string of the last error occurred. + */ + CString getErrorString() + {   CString error = CRegBaseCommon<CString>::getErrorString();  #if defined IDS_REG_ERROR - CString sTemp; - sTemp.Format(IDS_REG_ERROR, (LPCTSTR)m_key, (LPCTSTR)error); - return sTemp; + CString sTemp; + sTemp.Format(IDS_REG_ERROR, (LPCTSTR)m_key, (LPCTSTR)error); + return sTemp;  #else - return error; + return error;  #endif - }; + };  };  #endif   @@ -241,13 +241,13 @@
  /** Default constructor.   */   CRegStdBase(); - /** - * Constructor. - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" - * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ - CRegStdBase(const tstring& key, bool force, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); + /** + * Constructor. + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" + * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */ + CRegStdBase(const tstring& key, bool force, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0);  };    /** @@ -269,9 +269,9 @@
  * value of 100 is used when accessing the variable.   * now the variable can be used like any other DWORD variable:   * \code - * regvalue = 200; //stores the value 200 in the registry - * int temp = regvalue + 300; //temp has value 500 now - * regvalue += 300; //now the registry has the value 500 too + * regvalue = 200; //stores the value 200 in the registry + * int temp = regvalue + 300; //temp has value 500 now + * regvalue += 300; //now the registry has the value 500 too   * \endcode   * to avoid too much access to the registry the value is cached inside the object.   * once the value is read, no more read accesses to the registry will be made. @@ -293,8 +293,8 @@
 {  private:   - T m_value; ///< the cached value of the registry - T m_defaultvalue; ///< the default value to use + T m_value; ///< the cached value of the registry + T m_defaultvalue; ///< the default value to use     /**   * time stamp of the last registry lookup, i.e \ref read() call @@ -334,38 +334,38 @@
  typedef T ValueT;     /** - * Constructor. + * Constructor.   * We use this instead of a default constructor because not all   * data types may provide an adequate default constructor.   */ - CRegTypedBase(const T& def); + CRegTypedBase(const T& def);   - /** - * Constructor. - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" - * \param def the default value used when the key does not exist or a read error occurred - * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ + /** + * Constructor. + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" + * \param def the default value used when the key does not exist or a read error occurred + * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */   CRegTypedBase(const typename Base::StringT& key, const T& def, bool force = FALSE, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0);   - /** - * Constructor. - * \param updateInterval time in msec between registry lookups caused by operator const T& - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" - * \param def the default value used when the key does not exist or a read error occurred - * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ + /** + * Constructor. + * \param updateInterval time in msec between registry lookups caused by operator const T& + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" + * \param def the default value used when the key does not exist or a read error occurred + * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */   CRegTypedBase(DWORD updateInterval, const typename Base::StringT& key, const T& def, bool force = FALSE, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0);   - /** - * reads the assigned value from the registry. Use this method only if you think the registry - * value could have been altered without using the CRegDWORD object. - * \return the read value - */ - void read(); ///< reads the value from the registry - void write(); ///< writes the value to the registry + /** + * reads the assigned value from the registry. Use this method only if you think the registry + * value could have been altered without using the CRegDWORD object. + * \return the read value + */ + void read(); ///< reads the value from the registry + void write(); ///< writes the value to the registry     bool exists(); ///< test whether registry entry exits   const T& defaultValue() const; ///< return the default passed to the constructor @@ -375,7 +375,7 @@
  */     operator const T&(); - CRegTypedBase<T,Base>& operator=(const T& rhs); + CRegTypedBase<T,Base>& operator=(const T& rhs);  };    // implement CRegTypedBase<> members @@ -426,25 +426,25 @@
 template<class T, class Base>  void CRegTypedBase<T, Base>::read()  { - m_value = m_defaultvalue; + m_value = m_defaultvalue;   m_exists = false;     HKEY hKey = NULL; - if ((LastError = RegOpenKeyEx (m_base, GetPlainString (m_path), 0, KEY_EXECUTE|m_sam, &hKey))==ERROR_SUCCESS) - { - m_read = true; + if ((LastError = RegOpenKeyEx (m_base, GetPlainString (m_path), 0, KEY_EXECUTE|m_sam, &hKey))==ERROR_SUCCESS) + { + m_read = true;     T value = m_defaultvalue;   InternalRead (hKey, value);   - if (LastError ==ERROR_SUCCESS) - { + if (LastError ==ERROR_SUCCESS) + {   m_exists = true; - m_value = value; - } + m_value = value; + }     LastError = RegCloseKey(hKey); - } + }     lastRead = GetTickCount();  } @@ -455,18 +455,18 @@
  HKEY hKey = NULL;     DWORD disp = 0; - if ((LastError = RegCreateKeyEx(m_base, GetPlainString (m_path), 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_WRITE|m_sam, NULL, &hKey, &disp))!=ERROR_SUCCESS) - { - return; - } + if ((LastError = RegCreateKeyEx(m_base, GetPlainString (m_path), 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_WRITE|m_sam, NULL, &hKey, &disp))!=ERROR_SUCCESS) + { + return; + }     InternalWrite (hKey, m_value); - if (LastError ==ERROR_SUCCESS) - { - m_read = true; + if (LastError ==ERROR_SUCCESS) + { + m_read = true;   m_exists = true; - } - LastError = RegCloseKey(hKey); + } + LastError = RegCloseKey(hKey);     lastRead = GetTickCount();  } @@ -490,30 +490,30 @@
 CRegTypedBase<T, Base>::operator const T&()  {   HandleAutoRefresh(); - if ((m_read)&&(!m_force)) - { - LastError = ERROR_SUCCESS; - } - else - { - read(); - } + if ((m_read)&&(!m_force)) + { + LastError = ERROR_SUCCESS; + } + else + { + read(); + }   - return m_value; + return m_value;  }    template<class T, class Base>  CRegTypedBase<T, Base>& CRegTypedBase<T, Base>::operator =(const T& d)  { - if (m_read && (d == m_value) && !m_force) - { - //no write to the registry required, its the same value - LastError = ERROR_SUCCESS; - return *this; - } - m_value = d; - write(); - return *this; + if (m_read && (d == m_value) && !m_force) + { + //no write to the registry required, its the same value + LastError = ERROR_SUCCESS; + return *this; + } + m_value = d; + write(); + return *this;  }    /** @@ -535,9 +535,9 @@
  * value of 100 is used when accessing the variable.   * now the variable can be used like any other DWORD variable:   * \code - * regvalue = 200; //stores the value 200 in the registry - * int temp = regvalue + 300; //temp has value 500 now - * regvalue += 300; //now the registry has the value 500 too + * regvalue = 200; //stores the value 200 in the registry + * int temp = regvalue + 300; //temp has value 500 now + * regvalue += 300; //now the registry has the value 500 too   * \endcode   * to avoid too much access to the registry the value is cached inside the object.   * once the value is read, no more read accesses to the registry will be made. @@ -568,28 +568,28 @@
   public:   - CRegDWORDCommon(void); - /** - * Constructor. - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" - * \param def the default value used when the key does not exist or a read error occurred - * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ + CRegDWORDCommon(void); + /** + * Constructor. + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" + * \param def the default value used when the key does not exist or a read error occurred + * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */   CRegDWORDCommon(const typename Base::StringT& key, DWORD def = 0, bool force = false, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0);   CRegDWORDCommon(DWORD lookupInterval, const typename Base::StringT& key, DWORD def = 0, bool force = false, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0);     CRegDWORDCommon& operator=(DWORD rhs) {CRegTypedBase<DWORD, Base>::operator =(rhs); return *this;} - CRegDWORDCommon& operator+=(DWORD d) { return *this = *this + d;} - CRegDWORDCommon& operator-=(DWORD d) { return *this = *this - d;} - CRegDWORDCommon& operator*=(DWORD d) { return *this = *this * d;} - CRegDWORDCommon& operator/=(DWORD d) { return *this = *this / d;} - CRegDWORDCommon& operator%=(DWORD d) { return *this = *this % d;} - CRegDWORDCommon& operator<<=(DWORD d) { return *this = *this << d;} - CRegDWORDCommon& operator>>=(DWORD d) { return *this = *this >> d;} - CRegDWORDCommon& operator&=(DWORD d) { return *this = *this & d;} - CRegDWORDCommon& operator|=(DWORD d) { return *this = *this | d;} - CRegDWORDCommon& operator^=(DWORD d) { return *this = *this ^ d;} + CRegDWORDCommon& operator+=(DWORD d) { return *this = *this + d;} + CRegDWORDCommon& operator-=(DWORD d) { return *this = *this - d;} + CRegDWORDCommon& operator*=(DWORD d) { return *this = *this * d;} + CRegDWORDCommon& operator/=(DWORD d) { return *this = *this / d;} + CRegDWORDCommon& operator%=(DWORD d) { return *this = *this % d;} + CRegDWORDCommon& operator<<=(DWORD d) { return *this = *this << d;} + CRegDWORDCommon& operator>>=(DWORD d) { return *this = *this >> d;} + CRegDWORDCommon& operator&=(DWORD d) { return *this = *this & d;} + CRegDWORDCommon& operator|=(DWORD d) { return *this = *this | d;} + CRegDWORDCommon& operator^=(DWORD d) { return *this = *this ^ d;}  };    // implement CRegDWORDCommon<> methods @@ -616,17 +616,17 @@
 void CRegDWORDCommon<Base>::InternalRead (HKEY hKey, DWORD& value)  {   DWORD size = sizeof(value); - DWORD type = 0; - if ((LastError = RegQueryValueEx(hKey, GetPlainString (m_key), NULL, &type, (BYTE*) &value, &size))==ERROR_SUCCESS) + DWORD type = 0; + if ((LastError = RegQueryValueEx(hKey, GetPlainString (m_key), NULL, &type, (BYTE*) &value, &size))==ERROR_SUCCESS)   { - ASSERT(type==REG_DWORD); + ASSERT(type==REG_DWORD);   }  }    template<class Base>  void CRegDWORDCommon<Base>::InternalWrite (HKEY hKey, const DWORD& value)  { - LastError = RegSetValueEx (hKey, GetPlainString (m_key), 0, REG_DWORD,(const BYTE*) &value, sizeof(value)); + LastError = RegSetValueEx (hKey, GetPlainString (m_key), 0, REG_DWORD,(const BYTE*) &value, sizeof(value));  }    /** @@ -648,8 +648,8 @@
  * value of "default" is used when accessing the variable.   * now the variable can be used like any other CString variable:   * \code - * regvalue = "some string"; //stores the value "some string" in the registry - * CString temp = regvalue + "!!"; //temp has value "some string!!" now + * regvalue = "some string"; //stores the value "some string" in the registry + * CString temp = regvalue + "!!"; //temp has value "some string!!" now   * \endcode   * to use the normal methods of the CString class, just typecast the CRegString to a CString   * and do whatever you want with the string: @@ -688,19 +688,19 @@
  virtual void InternalWrite (HKEY hKey, const typename Base::StringT& value);    public: - CRegStringCommon(); - /** - * Constructor. - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" - * \param def the default value used when the key does not exist or a read error occurred - * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ + CRegStringCommon(); + /** + * Constructor. + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" + * \param def the default value used when the key does not exist or a read error occurred + * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */   CRegStringCommon(const typename Base::StringT& key, const typename Base::StringT& def = _T(""), bool force = false, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0);   CRegStringCommon(DWORD lookupInterval, const typename Base::StringT& key, const typename Base::StringT& def = _T(""), bool force = false, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); - +   CRegStringCommon& operator=(const typename Base::StringT& rhs) {CRegTypedBase<StringT, Base>::operator =(rhs); return *this;} - CRegStringCommon& operator+=(const typename Base::StringT& s) { return *this = (typename Base::StringT)*this + s; } + CRegStringCommon& operator+=(const typename Base::StringT& s) { return *this = (typename Base::StringT)*this + s; }  };    // implement CRegDWORD<> methods @@ -726,12 +726,12 @@
 template<class Base>  void CRegStringCommon<Base>::InternalRead (HKEY hKey, typename Base::StringT& value)  { - DWORD size = 0; - DWORD type = 0; - LastError = RegQueryValueEx(hKey, GetPlainString (m_key), NULL, &type, NULL, &size); + DWORD size = 0; + DWORD type = 0; + LastError = RegQueryValueEx(hKey, GetPlainString (m_key), NULL, &type, NULL, &size);     auto_buffer<TCHAR> pStr (size); - if ((LastError = RegQueryValueEx(hKey, GetPlainString (m_key), NULL, &type, (BYTE*) pStr.get(), &size))==ERROR_SUCCESS) + if ((LastError = RegQueryValueEx(hKey, GetPlainString (m_key), NULL, &type, (BYTE*) pStr.get(), &size))==ERROR_SUCCESS)   {   ASSERT(type==REG_SZ || type==REG_EXPAND_SZ);   value = StringT (pStr.get()); @@ -741,7 +741,7 @@
 template<class Base>  void CRegStringCommon<Base>::InternalWrite (HKEY hKey, const typename Base::StringT& value)  { - LastError = RegSetValueEx(hKey, GetPlainString (m_key), 0, REG_SZ, (BYTE *)GetPlainString (value), (GetLength(value)+1)*sizeof (TCHAR)); + LastError = RegSetValueEx(hKey, GetPlainString (m_key), 0, REG_SZ, (BYTE *)GetPlainString (value), (GetLength(value)+1)*sizeof (TCHAR));  }    /** @@ -763,7 +763,7 @@
  * value of 100,100,200,200 is used when accessing the variable.   * now the variable can be used like any other CRect variable:   * \code - * regvalue = CRect(40,20,300,500); //stores the value in the registry + * regvalue = CRect(40,20,300,500); //stores the value in the registry   * CRect temp = regvalue + CPoint(1,1);   * temp |= CSize(5,5);   * \endcode @@ -805,29 +805,29 @@
  virtual void InternalWrite (HKEY hKey, const CRect& value);    public: - CRegRect(); - /** - * Constructor. - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" - * \param def the default value used when the key does not exist or a read error occurred - * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ - CRegRect(const CString& key, const CRect& def = CRect(), bool force = false, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); - ~CRegRect(void); - + CRegRect(); + /** + * Constructor. + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" + * \param def the default value used when the key does not exist or a read error occurred + * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */ + CRegRect(const CString& key, const CRect& def = CRect(), bool force = false, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); + ~CRegRect(void); +   CRegRect& operator=(const CRect& rhs) {CRegTypedBase<CRect, CRegBase>::operator =(rhs); return *this;} - operator LPCRECT() { return (LPCRECT)(CRect)*this; } - operator LPRECT() { return (LPRECT)(CRect)*this; } - CRegRect& operator+=(POINT r) { return *this = (CRect)*this + r;} - CRegRect& operator+=(SIZE r) { return *this = (CRect)*this + r;} - CRegRect& operator+=(LPCRECT r) { return *this = (CRect)*this + r;} - CRegRect& operator-=(POINT r) { return *this = (CRect)*this - r;} - CRegRect& operator-=(SIZE r) { return *this = (CRect)*this - r;} - CRegRect& operator-=(LPCRECT r) { return *this = (CRect)*this - r;} - - CRegRect& operator&=(CRect r) { return *this = r & *this;} - CRegRect& operator|=(CRect r) { return *this = r | *this;} + operator LPCRECT() { return (LPCRECT)(CRect)*this; } + operator LPRECT() { return (LPRECT)(CRect)*this; } + CRegRect& operator+=(POINT r) { return *this = (CRect)*this + r;} + CRegRect& operator+=(SIZE r) { return *this = (CRect)*this + r;} + CRegRect& operator+=(LPCRECT r) { return *this = (CRect)*this + r;} + CRegRect& operator-=(POINT r) { return *this = (CRect)*this - r;} + CRegRect& operator-=(SIZE r) { return *this = (CRect)*this - r;} + CRegRect& operator-=(LPCRECT r) { return *this = (CRect)*this - r;} + + CRegRect& operator&=(CRect r) { return *this = r & *this;} + CRegRect& operator|=(CRect r) { return *this = r | *this;}  };  #endif   @@ -850,7 +850,7 @@
  * value of 100,100 is used when accessing the variable.   * now the variable can be used like any other CPoint variable:   * \code - * regvalue = CPoint(40,20); //stores the value in the registry + * regvalue = CPoint(40,20); //stores the value in the registry   * CPoint temp = regvalue + CPoint(1,1);   * temp += CSize(5,5);   * \endcode @@ -891,20 +891,20 @@
  virtual void InternalWrite (HKEY hKey, const CPoint& value);    public: - CRegPoint(); - /** - * Constructor. - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" - * \param def the default value used when the key does not exist or a read error occurred - * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ - CRegPoint(const CString& key, const CPoint& def = CPoint(), bool force = false, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); - ~CRegPoint(void); - + CRegPoint(); + /** + * Constructor. + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey\\MyValue" + * \param def the default value used when the key does not exist or a read error occurred + * \param force set to TRUE if no cache should be used, i.e. always read and write directly from/to registry + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */ + CRegPoint(const CString& key, const CPoint& def = CPoint(), bool force = false, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); + ~CRegPoint(void); +   CRegPoint& operator=(const CPoint& rhs) {CRegTypedBase<CPoint, CRegBase>::operator =(rhs); return *this;} - CRegPoint& operator+=(CPoint p) { return *this = p + *this; } - CRegPoint& operator-=(CPoint p) { return *this = p - *this; } + CRegPoint& operator+=(CPoint p) { return *this = p + *this; } + CRegPoint& operator-=(CPoint p) { return *this = p - *this; }  };  #endif   @@ -918,35 +918,35 @@
 class CRegistryKey  {  public: //methods - /** - * Constructor. - * \param key the path to the key, including the key. example: "Software\\Company\\SubKey" - * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. - */ - CRegistryKey(const CString& key, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); - ~CRegistryKey(); + /** + * Constructor. + * \param key the path to the key, including the key. example: "Software\\Company\\SubKey" + * \param base a predefined base key like HKEY_LOCAL_MACHINE. see the SDK documentation for more information. + */ + CRegistryKey(const CString& key, HKEY base = HKEY_CURRENT_USER, REGSAM sam = 0); + ~CRegistryKey();   - /** - * Creates the registry key if it does not already exist. - * \return ERROR_SUCCESS or an nonzero error code. Use FormatMessage() to get an error description. - */ - DWORD createKey(); - /** - * Removes the whole registry key including all values. So if you set the registry - * entry to be HKCU\Software\Company\Product\key there will only be - * HKCU\Software\Company\Product key in the registry. - * \return ERROR_SUCCESS or an nonzero error code. Use FormatMessage() to get an error description. - */ - DWORD removeKey(); + /** + * Creates the registry key if it does not already exist. + * \return ERROR_SUCCESS or an nonzero error code. Use FormatMessage() to get an error description. + */ + DWORD createKey(); + /** + * Removes the whole registry key including all values. So if you set the registry + * entry to be HKCU\Software\Company\Product\key there will only be + * HKCU\Software\Company\Product key in the registry. + * \return ERROR_SUCCESS or an nonzero error code. Use FormatMessage() to get an error description. + */ + DWORD removeKey();   - bool getValues(CStringList& values); ///< returns the list of values - bool getSubKeys(CStringList& subkeys); ///< returns the list of sub keys + bool getValues(CStringList& values); ///< returns the list of values + bool getSubKeys(CStringList& subkeys); ///< returns the list of sub keys   -public: //members - HKEY m_base; ///< handle to the registry base - HKEY m_hKey; ///< handle to the open registry key - REGSAM m_sam; ///< the security attributes to pass to the registry command - CString m_path; ///< the path to the key +public: //members + HKEY m_base; ///< handle to the registry base + HKEY m_hKey; ///< handle to the open registry key + REGSAM m_sam; ///< the security attributes to pass to the registry command + CString m_path; ///< the path to the key  };  #endif  
 
3
4
5
6
 
7
8
9
10
11
12
13
14
15
16
 
 
 
 
 
 
 
 
 
17
18
 
19
20
21
22
23
24
25
26
27
28
29
 
 
 
 
 
30
31
 
3
4
5
 
6
7
 
 
 
 
 
 
 
 
 
8
9
10
11
12
13
14
15
16
17
 
18
19
20
21
22
23
24
 
 
 
 
 
25
26
27
28
29
30
31
@@ -3,29 +3,29 @@
 // Used by shellext.rc  //   -#define IDS_APP_TITLE 103 +#define IDS_APP_TITLE 103   -#define IDR_MAINFRAME 128 -#define IDD_SHELLEXT_DIALOG 102 -#define IDD_ABOUTBOX 103 -#define IDM_ABOUT 104 -#define IDM_EXIT 105 -#define IDI_SHELLEXT 107 -#define IDI_SMALL 108 -#define IDC_SHELLEXT 109 -#define IDC_MYICON 2 +#define IDR_MAINFRAME 128 +#define IDD_SHELLEXT_DIALOG 102 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_SHELLEXT 107 +#define IDI_SMALL 108 +#define IDC_SHELLEXT 109 +#define IDC_MYICON 2  #ifndef IDC_STATIC -#define IDC_STATIC -1 +#define IDC_STATIC -1  #endif  // Next default values for new objects  //  #ifdef APSTUDIO_INVOKED  #ifndef APSTUDIO_READONLY_SYMBOLS   -#define _APS_NO_MFC 130 -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 +#define _APS_NO_MFC 130 +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110  #endif  #endif