2 * Copyright 2009 Vincent Povirk for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define WIN32_NO_STATUS
21 #define COM_NO_WINDOWS_H
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
32 //#include "winuser.h"
34 //#include "winerror.h"
38 //#include "wincodec.h"
39 #include <wincodecsdk.h>
41 #include <wine/debug.h>
42 #include <wine/unicode.h>
44 #include "wincodecs_private.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs
);
48 /***********************************************************************
49 * interface for self-registering
51 struct decoder_pattern
53 DWORD length
; /* 0 for end of list */
62 CLSID
const *clsid
; /* NULL for end of list */
67 GUID
const *container_format
;
70 GUID
const * const *formats
;
71 const struct decoder_pattern
*patterns
;
74 static HRESULT
register_decoders(struct regsvr_decoder
const *list
);
75 static HRESULT
unregister_decoders(struct regsvr_decoder
const *list
);
79 CLSID
const *clsid
; /* NULL for end of list */
84 GUID
const *container_format
;
87 GUID
const * const *formats
;
90 static HRESULT
register_encoders(struct regsvr_encoder
const *list
);
91 static HRESULT
unregister_encoders(struct regsvr_encoder
const *list
);
93 struct regsvr_converter
95 CLSID
const *clsid
; /* NULL for end of list */
100 GUID
const * const *formats
;
103 static HRESULT
register_converters(struct regsvr_converter
const *list
);
104 static HRESULT
unregister_converters(struct regsvr_converter
const *list
);
106 struct metadata_pattern
115 struct reader_containers
118 const struct metadata_pattern
*patterns
;
121 struct regsvr_metadatareader
123 CLSID
const *clsid
; /* NULL for end of list */
129 GUID
const *metadata_format
;
130 DWORD requires_fullstream
;
131 DWORD supports_padding
;
132 DWORD requires_fixedsize
;
133 const struct reader_containers
*containers
;
136 static HRESULT
register_metadatareaders(struct regsvr_metadatareader
const *list
);
137 static HRESULT
unregister_metadatareaders(struct regsvr_metadatareader
const *list
);
139 struct regsvr_pixelformat
141 CLSID
const *clsid
; /* NULL for end of list */
148 BYTE
const * const *channelmasks
;
149 WICPixelFormatNumericRepresentation numericrepresentation
;
153 static HRESULT
register_pixelformats(struct regsvr_pixelformat
const *list
);
154 static HRESULT
unregister_pixelformats(struct regsvr_pixelformat
const *list
);
156 /***********************************************************************
157 * static string constants
159 static const WCHAR clsid_keyname
[] = {
160 'C', 'L', 'S', 'I', 'D', 0 };
161 static const WCHAR curver_keyname
[] = {
162 'C', 'u', 'r', 'V', 'e', 'r', 0 };
163 static const WCHAR ips_keyname
[] = {
164 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
166 static const WCHAR ips32_keyname
[] = {
167 'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
169 static const WCHAR progid_keyname
[] = {
170 'P', 'r', 'o', 'g', 'I', 'D', 0 };
171 static const WCHAR viprogid_keyname
[] = {
172 'V', 'e', 'r', 's', 'i', 'o', 'n', 'I', 'n', 'd', 'e', 'p',
173 'e', 'n', 'd', 'e', 'n', 't', 'P', 'r', 'o', 'g', 'I', 'D',
175 static const char tmodel_valuename
[] = "ThreadingModel";
176 static const char author_valuename
[] = "Author";
177 static const char friendlyname_valuename
[] = "FriendlyName";
178 static const WCHAR vendor_valuename
[] = {'V','e','n','d','o','r',0};
179 static const WCHAR containerformat_valuename
[] = {'C','o','n','t','a','i','n','e','r','F','o','r','m','a','t',0};
180 static const char version_valuename
[] = "Version";
181 static const char mimetypes_valuename
[] = "MimeTypes";
182 static const char extensions_valuename
[] = "FileExtensions";
183 static const WCHAR formats_keyname
[] = {'F','o','r','m','a','t','s',0};
184 static const WCHAR patterns_keyname
[] = {'P','a','t','t','e','r','n','s',0};
185 static const WCHAR instance_keyname
[] = {'I','n','s','t','a','n','c','e',0};
186 static const WCHAR clsid_valuename
[] = {'C','L','S','I','D',0};
187 static const char length_valuename
[] = "Length";
188 static const char position_valuename
[] = "Position";
189 static const char pattern_valuename
[] = "Pattern";
190 static const char mask_valuename
[] = "Mask";
191 static const char endofstream_valuename
[] = "EndOfStream";
192 static const WCHAR pixelformats_keyname
[] = {'P','i','x','e','l','F','o','r','m','a','t','s',0};
193 static const WCHAR metadataformat_valuename
[] = {'M','e','t','a','d','a','t','a','F','o','r','m','a','t',0};
194 static const char specversion_valuename
[] = "SpecVersion";
195 static const char requiresfullstream_valuename
[] = "RequiresFullStream";
196 static const char supportspadding_valuename
[] = "SupportsPadding";
197 static const char requiresfixedsize_valuename
[] = "FixedSize";
198 static const WCHAR containers_keyname
[] = {'C','o','n','t','a','i','n','e','r','s',0};
199 static const char dataoffset_valuename
[] = "DataOffset";
200 static const char bitsperpixel_valuename
[] = "BitLength";
201 static const char channelcount_valuename
[] = "ChannelCount";
202 static const char numericrepresentation_valuename
[] = "NumericRepresentation";
203 static const char supportstransparency_valuename
[] = "SupportsTransparency";
204 static const WCHAR channelmasks_keyname
[] = {'C','h','a','n','n','e','l','M','a','s','k','s',0};
206 /***********************************************************************
209 static HRESULT
register_decoders(struct regsvr_decoder
const *list
)
211 LONG res
= ERROR_SUCCESS
;
217 res
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, NULL
, 0,
218 KEY_READ
| KEY_WRITE
, NULL
, &coclass_key
, NULL
);
219 if (res
== ERROR_SUCCESS
) {
220 StringFromGUID2(&CATID_WICBitmapDecoders
, buf
, 39);
221 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
222 KEY_READ
| KEY_WRITE
, NULL
, &decoders_key
, NULL
);
223 if (res
== ERROR_SUCCESS
)
225 res
= RegCreateKeyExW(decoders_key
, instance_keyname
, 0, NULL
, 0,
226 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
227 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
229 if (res
!= ERROR_SUCCESS
)
230 RegCloseKey(coclass_key
);
232 if (res
!= ERROR_SUCCESS
) goto error_return
;
234 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
236 HKEY instance_clsid_key
;
238 StringFromGUID2(list
->clsid
, buf
, 39);
239 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
240 KEY_READ
| KEY_WRITE
, NULL
, &clsid_key
, NULL
);
241 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
243 StringFromGUID2(list
->clsid
, buf
, 39);
244 res
= RegCreateKeyExW(instance_key
, buf
, 0, NULL
, 0,
245 KEY_READ
| KEY_WRITE
, NULL
, &instance_clsid_key
, NULL
);
246 if (res
== ERROR_SUCCESS
) {
247 res
= RegSetValueExW(instance_clsid_key
, clsid_valuename
, 0, REG_SZ
,
248 (CONST BYTE
*)(buf
), 78);
249 RegCloseKey(instance_clsid_key
);
251 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
254 res
= RegSetValueExA(clsid_key
, author_valuename
, 0, REG_SZ
,
255 (CONST BYTE
*)(list
->author
),
256 strlen(list
->author
) + 1);
257 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
260 if (list
->friendlyname
) {
261 res
= RegSetValueExA(clsid_key
, friendlyname_valuename
, 0, REG_SZ
,
262 (CONST BYTE
*)(list
->friendlyname
),
263 strlen(list
->friendlyname
) + 1);
264 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
268 StringFromGUID2(list
->vendor
, buf
, 39);
269 res
= RegSetValueExW(clsid_key
, vendor_valuename
, 0, REG_SZ
,
270 (CONST BYTE
*)(buf
), 78);
271 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
274 if (list
->container_format
) {
275 StringFromGUID2(list
->container_format
, buf
, 39);
276 res
= RegSetValueExW(clsid_key
, containerformat_valuename
, 0, REG_SZ
,
277 (CONST BYTE
*)(buf
), 78);
278 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
282 res
= RegSetValueExA(clsid_key
, version_valuename
, 0, REG_SZ
,
283 (CONST BYTE
*)(list
->version
),
284 strlen(list
->version
) + 1);
285 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
288 if (list
->mimetypes
) {
289 res
= RegSetValueExA(clsid_key
, mimetypes_valuename
, 0, REG_SZ
,
290 (CONST BYTE
*)(list
->mimetypes
),
291 strlen(list
->mimetypes
) + 1);
292 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
295 if (list
->extensions
) {
296 res
= RegSetValueExA(clsid_key
, extensions_valuename
, 0, REG_SZ
,
297 (CONST BYTE
*)(list
->extensions
),
298 strlen(list
->extensions
) + 1);
299 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
304 GUID
const * const *format
;
306 res
= RegCreateKeyExW(clsid_key
, formats_keyname
, 0, NULL
, 0,
307 KEY_READ
| KEY_WRITE
, NULL
, &formats_key
, NULL
);
308 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
309 for (format
=list
->formats
; *format
; ++format
)
312 StringFromGUID2(*format
, buf
, 39);
313 res
= RegCreateKeyExW(formats_key
, buf
, 0, NULL
, 0,
314 KEY_READ
| KEY_WRITE
, NULL
, &format_key
, NULL
);
315 if (res
!= ERROR_SUCCESS
) break;
316 RegCloseKey(format_key
);
318 RegCloseKey(formats_key
);
319 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
322 if (list
->patterns
) {
326 res
= RegCreateKeyExW(clsid_key
, patterns_keyname
, 0, NULL
, 0,
327 KEY_READ
| KEY_WRITE
, NULL
, &patterns_key
, NULL
);
328 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
329 for (i
=0; list
->patterns
[i
].length
; i
++)
332 static const WCHAR int_format
[] = {'%','i',0};
333 snprintfW(buf
, 39, int_format
, i
);
334 res
= RegCreateKeyExW(patterns_key
, buf
, 0, NULL
, 0,
335 KEY_READ
| KEY_WRITE
, NULL
, &pattern_key
, NULL
);
336 if (res
!= ERROR_SUCCESS
) break;
337 res
= RegSetValueExA(pattern_key
, length_valuename
, 0, REG_DWORD
,
338 (CONST BYTE
*)(&list
->patterns
[i
].length
), 4);
339 if (res
== ERROR_SUCCESS
)
340 res
= RegSetValueExA(pattern_key
, position_valuename
, 0, REG_DWORD
,
341 (CONST BYTE
*)(&list
->patterns
[i
].position
), 4);
342 if (res
== ERROR_SUCCESS
)
343 res
= RegSetValueExA(pattern_key
, pattern_valuename
, 0, REG_BINARY
,
344 list
->patterns
[i
].pattern
,
345 list
->patterns
[i
].length
);
346 if (res
== ERROR_SUCCESS
)
347 res
= RegSetValueExA(pattern_key
, mask_valuename
, 0, REG_BINARY
,
348 list
->patterns
[i
].mask
,
349 list
->patterns
[i
].length
);
350 if (res
== ERROR_SUCCESS
)
351 res
= RegSetValueExA(pattern_key
, endofstream_valuename
, 0, REG_DWORD
,
352 (CONST BYTE
*)&(list
->patterns
[i
].endofstream
), 4);
353 RegCloseKey(pattern_key
);
355 RegCloseKey(patterns_key
);
356 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
359 error_close_clsid_key
:
360 RegCloseKey(clsid_key
);
363 error_close_coclass_key
:
364 RegCloseKey(instance_key
);
365 RegCloseKey(decoders_key
);
366 RegCloseKey(coclass_key
);
368 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
371 /***********************************************************************
372 * unregister_decoders
374 static HRESULT
unregister_decoders(struct regsvr_decoder
const *list
)
376 LONG res
= ERROR_SUCCESS
;
382 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0,
383 KEY_READ
| KEY_WRITE
, &coclass_key
);
384 if (res
== ERROR_FILE_NOT_FOUND
) return S_OK
;
386 if (res
== ERROR_SUCCESS
) {
387 StringFromGUID2(&CATID_WICBitmapDecoders
, buf
, 39);
388 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
389 KEY_READ
| KEY_WRITE
, NULL
, &decoders_key
, NULL
);
390 if (res
== ERROR_SUCCESS
)
392 res
= RegCreateKeyExW(decoders_key
, instance_keyname
, 0, NULL
, 0,
393 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
394 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
396 if (res
!= ERROR_SUCCESS
)
397 RegCloseKey(coclass_key
);
399 if (res
!= ERROR_SUCCESS
) goto error_return
;
401 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
402 StringFromGUID2(list
->clsid
, buf
, 39);
404 res
= RegDeleteTreeW(coclass_key
, buf
);
405 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
406 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
408 res
= RegDeleteTreeW(instance_key
, buf
);
409 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
410 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
413 error_close_coclass_key
:
414 RegCloseKey(instance_key
);
415 RegCloseKey(decoders_key
);
416 RegCloseKey(coclass_key
);
418 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
421 /***********************************************************************
424 static HRESULT
register_encoders(struct regsvr_encoder
const *list
)
426 LONG res
= ERROR_SUCCESS
;
432 res
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, NULL
, 0,
433 KEY_READ
| KEY_WRITE
, NULL
, &coclass_key
, NULL
);
434 if (res
== ERROR_SUCCESS
) {
435 StringFromGUID2(&CATID_WICBitmapEncoders
, buf
, 39);
436 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
437 KEY_READ
| KEY_WRITE
, NULL
, &encoders_key
, NULL
);
438 if (res
== ERROR_SUCCESS
)
440 res
= RegCreateKeyExW(encoders_key
, instance_keyname
, 0, NULL
, 0,
441 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
442 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
444 if (res
!= ERROR_SUCCESS
)
445 RegCloseKey(coclass_key
);
447 if (res
!= ERROR_SUCCESS
) goto error_return
;
449 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
451 HKEY instance_clsid_key
;
453 StringFromGUID2(list
->clsid
, buf
, 39);
454 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
455 KEY_READ
| KEY_WRITE
, NULL
, &clsid_key
, NULL
);
456 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
458 StringFromGUID2(list
->clsid
, buf
, 39);
459 res
= RegCreateKeyExW(instance_key
, buf
, 0, NULL
, 0,
460 KEY_READ
| KEY_WRITE
, NULL
, &instance_clsid_key
, NULL
);
461 if (res
== ERROR_SUCCESS
) {
462 res
= RegSetValueExW(instance_clsid_key
, clsid_valuename
, 0, REG_SZ
,
463 (CONST BYTE
*)(buf
), 78);
464 RegCloseKey(instance_clsid_key
);
466 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
469 res
= RegSetValueExA(clsid_key
, author_valuename
, 0, REG_SZ
,
470 (CONST BYTE
*)(list
->author
),
471 strlen(list
->author
) + 1);
472 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
475 if (list
->friendlyname
) {
476 res
= RegSetValueExA(clsid_key
, friendlyname_valuename
, 0, REG_SZ
,
477 (CONST BYTE
*)(list
->friendlyname
),
478 strlen(list
->friendlyname
) + 1);
479 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
483 StringFromGUID2(list
->vendor
, buf
, 39);
484 res
= RegSetValueExW(clsid_key
, vendor_valuename
, 0, REG_SZ
,
485 (CONST BYTE
*)(buf
), 78);
486 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
489 if (list
->container_format
) {
490 StringFromGUID2(list
->container_format
, buf
, 39);
491 res
= RegSetValueExW(clsid_key
, containerformat_valuename
, 0, REG_SZ
,
492 (CONST BYTE
*)(buf
), 78);
493 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
497 res
= RegSetValueExA(clsid_key
, version_valuename
, 0, REG_SZ
,
498 (CONST BYTE
*)(list
->version
),
499 strlen(list
->version
) + 1);
500 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
503 if (list
->mimetypes
) {
504 res
= RegSetValueExA(clsid_key
, mimetypes_valuename
, 0, REG_SZ
,
505 (CONST BYTE
*)(list
->mimetypes
),
506 strlen(list
->mimetypes
) + 1);
507 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
510 if (list
->extensions
) {
511 res
= RegSetValueExA(clsid_key
, extensions_valuename
, 0, REG_SZ
,
512 (CONST BYTE
*)(list
->extensions
),
513 strlen(list
->extensions
) + 1);
514 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
519 GUID
const * const *format
;
521 res
= RegCreateKeyExW(clsid_key
, formats_keyname
, 0, NULL
, 0,
522 KEY_READ
| KEY_WRITE
, NULL
, &formats_key
, NULL
);
523 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
524 for (format
=list
->formats
; *format
; ++format
)
527 StringFromGUID2(*format
, buf
, 39);
528 res
= RegCreateKeyExW(formats_key
, buf
, 0, NULL
, 0,
529 KEY_READ
| KEY_WRITE
, NULL
, &format_key
, NULL
);
530 if (res
!= ERROR_SUCCESS
) break;
531 RegCloseKey(format_key
);
533 RegCloseKey(formats_key
);
534 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
537 error_close_clsid_key
:
538 RegCloseKey(clsid_key
);
541 error_close_coclass_key
:
542 RegCloseKey(instance_key
);
543 RegCloseKey(encoders_key
);
544 RegCloseKey(coclass_key
);
546 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
549 /***********************************************************************
550 * unregister_encoders
552 static HRESULT
unregister_encoders(struct regsvr_encoder
const *list
)
554 LONG res
= ERROR_SUCCESS
;
560 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0,
561 KEY_READ
| KEY_WRITE
, &coclass_key
);
562 if (res
== ERROR_FILE_NOT_FOUND
) return S_OK
;
564 if (res
== ERROR_SUCCESS
) {
565 StringFromGUID2(&CATID_WICBitmapEncoders
, buf
, 39);
566 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
567 KEY_READ
| KEY_WRITE
, NULL
, &encoders_key
, NULL
);
568 if (res
== ERROR_SUCCESS
)
570 res
= RegCreateKeyExW(encoders_key
, instance_keyname
, 0, NULL
, 0,
571 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
572 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
574 if (res
!= ERROR_SUCCESS
)
575 RegCloseKey(coclass_key
);
577 if (res
!= ERROR_SUCCESS
) goto error_return
;
579 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
580 StringFromGUID2(list
->clsid
, buf
, 39);
582 res
= RegDeleteTreeW(coclass_key
, buf
);
583 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
584 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
586 res
= RegDeleteTreeW(instance_key
, buf
);
587 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
588 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
591 error_close_coclass_key
:
592 RegCloseKey(instance_key
);
593 RegCloseKey(encoders_key
);
594 RegCloseKey(coclass_key
);
596 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
599 /***********************************************************************
600 * register_converters
602 static HRESULT
register_converters(struct regsvr_converter
const *list
)
604 LONG res
= ERROR_SUCCESS
;
610 res
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, NULL
, 0,
611 KEY_READ
| KEY_WRITE
, NULL
, &coclass_key
, NULL
);
612 if (res
== ERROR_SUCCESS
) {
613 StringFromGUID2(&CATID_WICFormatConverters
, buf
, 39);
614 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
615 KEY_READ
| KEY_WRITE
, NULL
, &converters_key
, NULL
);
616 if (res
== ERROR_SUCCESS
)
618 res
= RegCreateKeyExW(converters_key
, instance_keyname
, 0, NULL
, 0,
619 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
620 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
622 if (res
!= ERROR_SUCCESS
)
623 RegCloseKey(coclass_key
);
625 if (res
!= ERROR_SUCCESS
) goto error_return
;
627 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
629 HKEY instance_clsid_key
;
631 StringFromGUID2(list
->clsid
, buf
, 39);
632 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
633 KEY_READ
| KEY_WRITE
, NULL
, &clsid_key
, NULL
);
634 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
636 StringFromGUID2(list
->clsid
, buf
, 39);
637 res
= RegCreateKeyExW(instance_key
, buf
, 0, NULL
, 0,
638 KEY_READ
| KEY_WRITE
, NULL
, &instance_clsid_key
, NULL
);
639 if (res
== ERROR_SUCCESS
) {
640 res
= RegSetValueExW(instance_clsid_key
, clsid_valuename
, 0, REG_SZ
,
641 (CONST BYTE
*)(buf
), 78);
642 RegCloseKey(instance_clsid_key
);
644 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
647 res
= RegSetValueExA(clsid_key
, author_valuename
, 0, REG_SZ
,
648 (CONST BYTE
*)(list
->author
),
649 strlen(list
->author
) + 1);
650 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
653 if (list
->friendlyname
) {
654 res
= RegSetValueExA(clsid_key
, friendlyname_valuename
, 0, REG_SZ
,
655 (CONST BYTE
*)(list
->friendlyname
),
656 strlen(list
->friendlyname
) + 1);
657 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
661 StringFromGUID2(list
->vendor
, buf
, 39);
662 res
= RegSetValueExW(clsid_key
, vendor_valuename
, 0, REG_SZ
,
663 (CONST BYTE
*)(buf
), 78);
664 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
668 res
= RegSetValueExA(clsid_key
, version_valuename
, 0, REG_SZ
,
669 (CONST BYTE
*)(list
->version
),
670 strlen(list
->version
) + 1);
671 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
676 GUID
const * const *format
;
678 res
= RegCreateKeyExW(clsid_key
, pixelformats_keyname
, 0, NULL
, 0,
679 KEY_READ
| KEY_WRITE
, NULL
, &formats_key
, NULL
);
680 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
681 for (format
=list
->formats
; *format
; ++format
)
684 StringFromGUID2(*format
, buf
, 39);
685 res
= RegCreateKeyExW(formats_key
, buf
, 0, NULL
, 0,
686 KEY_READ
| KEY_WRITE
, NULL
, &format_key
, NULL
);
687 if (res
!= ERROR_SUCCESS
) break;
688 RegCloseKey(format_key
);
690 RegCloseKey(formats_key
);
691 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
694 error_close_clsid_key
:
695 RegCloseKey(clsid_key
);
698 error_close_coclass_key
:
699 RegCloseKey(instance_key
);
700 RegCloseKey(converters_key
);
701 RegCloseKey(coclass_key
);
703 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
706 /***********************************************************************
707 * unregister_converters
709 static HRESULT
unregister_converters(struct regsvr_converter
const *list
)
711 LONG res
= ERROR_SUCCESS
;
717 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0,
718 KEY_READ
| KEY_WRITE
, &coclass_key
);
719 if (res
== ERROR_FILE_NOT_FOUND
) return S_OK
;
721 if (res
== ERROR_SUCCESS
) {
722 StringFromGUID2(&CATID_WICFormatConverters
, buf
, 39);
723 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
724 KEY_READ
| KEY_WRITE
, NULL
, &converters_key
, NULL
);
725 if (res
== ERROR_SUCCESS
)
727 res
= RegCreateKeyExW(converters_key
, instance_keyname
, 0, NULL
, 0,
728 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
729 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
731 if (res
!= ERROR_SUCCESS
)
732 RegCloseKey(coclass_key
);
734 if (res
!= ERROR_SUCCESS
) goto error_return
;
736 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
737 StringFromGUID2(list
->clsid
, buf
, 39);
739 res
= RegDeleteTreeW(coclass_key
, buf
);
740 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
741 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
743 res
= RegDeleteTreeW(instance_key
, buf
);
744 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
745 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
748 error_close_coclass_key
:
749 RegCloseKey(instance_key
);
750 RegCloseKey(converters_key
);
751 RegCloseKey(coclass_key
);
753 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
756 /***********************************************************************
757 * register_metadatareaders
759 static HRESULT
register_metadatareaders(struct regsvr_metadatareader
const *list
)
761 LONG res
= ERROR_SUCCESS
;
767 res
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, NULL
, 0,
768 KEY_READ
| KEY_WRITE
, NULL
, &coclass_key
, NULL
);
769 if (res
== ERROR_SUCCESS
) {
770 StringFromGUID2(&CATID_WICMetadataReader
, buf
, 39);
771 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
772 KEY_READ
| KEY_WRITE
, NULL
, &readers_key
, NULL
);
773 if (res
== ERROR_SUCCESS
)
775 res
= RegCreateKeyExW(readers_key
, instance_keyname
, 0, NULL
, 0,
776 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
777 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
779 if (res
!= ERROR_SUCCESS
)
780 RegCloseKey(coclass_key
);
782 if (res
!= ERROR_SUCCESS
) goto error_return
;
784 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
786 HKEY instance_clsid_key
;
788 StringFromGUID2(list
->clsid
, buf
, 39);
789 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
790 KEY_READ
| KEY_WRITE
, NULL
, &clsid_key
, NULL
);
791 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
793 StringFromGUID2(list
->clsid
, buf
, 39);
794 res
= RegCreateKeyExW(instance_key
, buf
, 0, NULL
, 0,
795 KEY_READ
| KEY_WRITE
, NULL
, &instance_clsid_key
, NULL
);
796 if (res
== ERROR_SUCCESS
) {
797 res
= RegSetValueExW(instance_clsid_key
, clsid_valuename
, 0, REG_SZ
,
798 (CONST BYTE
*)(buf
), 78);
799 RegCloseKey(instance_clsid_key
);
801 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
804 res
= RegSetValueExA(clsid_key
, author_valuename
, 0, REG_SZ
,
805 (CONST BYTE
*)(list
->author
),
806 strlen(list
->author
) + 1);
807 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
810 if (list
->friendlyname
) {
811 res
= RegSetValueExA(clsid_key
, friendlyname_valuename
, 0, REG_SZ
,
812 (CONST BYTE
*)(list
->friendlyname
),
813 strlen(list
->friendlyname
) + 1);
814 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
818 StringFromGUID2(list
->vendor
, buf
, 39);
819 res
= RegSetValueExW(clsid_key
, vendor_valuename
, 0, REG_SZ
,
820 (CONST BYTE
*)(buf
), 78);
821 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
824 if (list
->metadata_format
) {
825 StringFromGUID2(list
->metadata_format
, buf
, 39);
826 res
= RegSetValueExW(clsid_key
, metadataformat_valuename
, 0, REG_SZ
,
827 (CONST BYTE
*)(buf
), 78);
828 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
832 res
= RegSetValueExA(clsid_key
, version_valuename
, 0, REG_SZ
,
833 (CONST BYTE
*)(list
->version
),
834 strlen(list
->version
) + 1);
835 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
838 if (list
->specversion
) {
839 res
= RegSetValueExA(clsid_key
, specversion_valuename
, 0, REG_SZ
,
840 (CONST BYTE
*)(list
->version
),
841 strlen(list
->version
) + 1);
842 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
845 res
= RegSetValueExA(clsid_key
, requiresfullstream_valuename
, 0, REG_DWORD
,
846 (CONST BYTE
*)(&list
->requires_fullstream
), 4);
847 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
849 res
= RegSetValueExA(clsid_key
, supportspadding_valuename
, 0, REG_DWORD
,
850 (CONST BYTE
*)(&list
->supports_padding
), 4);
851 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
853 if (list
->requires_fixedsize
) {
854 res
= RegSetValueExA(clsid_key
, requiresfixedsize_valuename
, 0, REG_DWORD
,
855 (CONST BYTE
*)(&list
->requires_fixedsize
), 4);
856 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
859 if (list
->containers
) {
861 const struct reader_containers
*container
;
863 res
= RegCreateKeyExW(clsid_key
, containers_keyname
, 0, NULL
, 0,
864 KEY_READ
| KEY_WRITE
, NULL
, &containers_key
, NULL
);
865 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
866 for (container
=list
->containers
; container
->format
; ++container
)
870 StringFromGUID2(container
->format
, buf
, 39);
871 res
= RegCreateKeyExW(containers_key
, buf
, 0, NULL
, 0,
872 KEY_READ
| KEY_WRITE
, NULL
, &format_key
, NULL
);
873 if (res
!= ERROR_SUCCESS
) break;
875 for (i
=0; container
->patterns
[i
].length
; i
++)
878 static const WCHAR int_format
[] = {'%','i',0};
879 snprintfW(buf
, 39, int_format
, i
);
880 res
= RegCreateKeyExW(format_key
, buf
, 0, NULL
, 0,
881 KEY_READ
| KEY_WRITE
, NULL
, &pattern_key
, NULL
);
882 if (res
!= ERROR_SUCCESS
) break;
883 res
= RegSetValueExA(pattern_key
, position_valuename
, 0, REG_DWORD
,
884 (CONST BYTE
*)(&container
->patterns
[i
].position
), 4);
885 if (res
== ERROR_SUCCESS
)
886 res
= RegSetValueExA(pattern_key
, pattern_valuename
, 0, REG_BINARY
,
887 container
->patterns
[i
].pattern
,
888 container
->patterns
[i
].length
);
889 if (res
== ERROR_SUCCESS
)
890 res
= RegSetValueExA(pattern_key
, mask_valuename
, 0, REG_BINARY
,
891 container
->patterns
[i
].mask
,
892 container
->patterns
[i
].length
);
893 if (res
== ERROR_SUCCESS
&& container
->patterns
[i
].data_offset
)
894 res
= RegSetValueExA(pattern_key
, dataoffset_valuename
, 0, REG_DWORD
,
895 (CONST BYTE
*)&(container
->patterns
[i
].data_offset
), 4);
896 RegCloseKey(pattern_key
);
899 RegCloseKey(format_key
);
901 RegCloseKey(containers_key
);
904 error_close_clsid_key
:
905 RegCloseKey(clsid_key
);
908 error_close_coclass_key
:
909 RegCloseKey(instance_key
);
910 RegCloseKey(readers_key
);
911 RegCloseKey(coclass_key
);
913 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
916 /***********************************************************************
917 * unregister_metadatareaders
919 static HRESULT
unregister_metadatareaders(struct regsvr_metadatareader
const *list
)
921 LONG res
= ERROR_SUCCESS
;
927 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0,
928 KEY_READ
| KEY_WRITE
, &coclass_key
);
929 if (res
== ERROR_FILE_NOT_FOUND
) return S_OK
;
931 if (res
== ERROR_SUCCESS
) {
932 StringFromGUID2(&CATID_WICMetadataReader
, buf
, 39);
933 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
934 KEY_READ
| KEY_WRITE
, NULL
, &readers_key
, NULL
);
935 if (res
== ERROR_SUCCESS
)
937 res
= RegCreateKeyExW(readers_key
, instance_keyname
, 0, NULL
, 0,
938 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
939 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
941 if (res
!= ERROR_SUCCESS
)
942 RegCloseKey(coclass_key
);
944 if (res
!= ERROR_SUCCESS
) goto error_return
;
946 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
947 StringFromGUID2(list
->clsid
, buf
, 39);
949 res
= RegDeleteTreeW(coclass_key
, buf
);
950 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
951 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
953 res
= RegDeleteTreeW(instance_key
, buf
);
954 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
955 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
958 error_close_coclass_key
:
959 RegCloseKey(instance_key
);
960 RegCloseKey(readers_key
);
961 RegCloseKey(coclass_key
);
963 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
966 /***********************************************************************
967 * register_pixelformats
969 static HRESULT
register_pixelformats(struct regsvr_pixelformat
const *list
)
971 LONG res
= ERROR_SUCCESS
;
977 res
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, NULL
, 0,
978 KEY_READ
| KEY_WRITE
, NULL
, &coclass_key
, NULL
);
979 if (res
== ERROR_SUCCESS
) {
980 StringFromGUID2(&CATID_WICPixelFormats
, buf
, 39);
981 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
982 KEY_READ
| KEY_WRITE
, NULL
, &formats_key
, NULL
);
983 if (res
== ERROR_SUCCESS
)
985 res
= RegCreateKeyExW(formats_key
, instance_keyname
, 0, NULL
, 0,
986 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
987 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
989 if (res
!= ERROR_SUCCESS
)
990 RegCloseKey(coclass_key
);
992 if (res
!= ERROR_SUCCESS
) goto error_return
;
994 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
996 HKEY instance_clsid_key
;
998 StringFromGUID2(list
->clsid
, buf
, 39);
999 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
1000 KEY_READ
| KEY_WRITE
, NULL
, &clsid_key
, NULL
);
1001 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
1003 StringFromGUID2(list
->clsid
, buf
, 39);
1004 res
= RegCreateKeyExW(instance_key
, buf
, 0, NULL
, 0,
1005 KEY_READ
| KEY_WRITE
, NULL
, &instance_clsid_key
, NULL
);
1006 if (res
== ERROR_SUCCESS
) {
1007 res
= RegSetValueExW(instance_clsid_key
, clsid_valuename
, 0, REG_SZ
,
1008 (CONST BYTE
*)(buf
), 78);
1009 RegCloseKey(instance_clsid_key
);
1011 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1014 res
= RegSetValueExA(clsid_key
, author_valuename
, 0, REG_SZ
,
1015 (CONST BYTE
*)(list
->author
),
1016 strlen(list
->author
) + 1);
1017 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1020 if (list
->friendlyname
) {
1021 res
= RegSetValueExA(clsid_key
, friendlyname_valuename
, 0, REG_SZ
,
1022 (CONST BYTE
*)(list
->friendlyname
),
1023 strlen(list
->friendlyname
) + 1);
1024 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1028 StringFromGUID2(list
->vendor
, buf
, 39);
1029 res
= RegSetValueExW(clsid_key
, vendor_valuename
, 0, REG_SZ
,
1030 (CONST BYTE
*)(buf
), 78);
1031 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1034 if (list
->version
) {
1035 res
= RegSetValueExA(clsid_key
, version_valuename
, 0, REG_SZ
,
1036 (CONST BYTE
*)(list
->version
),
1037 strlen(list
->version
) + 1);
1038 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1041 res
= RegSetValueExA(clsid_key
, bitsperpixel_valuename
, 0, REG_DWORD
,
1042 (CONST BYTE
*)(&list
->bitsperpixel
), 4);
1043 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1045 res
= RegSetValueExA(clsid_key
, channelcount_valuename
, 0, REG_DWORD
,
1046 (CONST BYTE
*)(&list
->channelcount
), 4);
1047 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1049 res
= RegSetValueExA(clsid_key
, numericrepresentation_valuename
, 0, REG_DWORD
,
1050 (CONST BYTE
*)(&list
->numericrepresentation
), 4);
1051 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1053 res
= RegSetValueExA(clsid_key
, supportstransparency_valuename
, 0, REG_DWORD
,
1054 (CONST BYTE
*)(&list
->supportsalpha
), 4);
1055 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1057 if (list
->channelmasks
) {
1060 WCHAR mask_valuename
[11];
1061 const WCHAR valuename_format
[] = {'%','d',0};
1063 mask_size
= (list
->bitsperpixel
+ 7)/8;
1065 res
= RegCreateKeyExW(clsid_key
, channelmasks_keyname
, 0, NULL
, 0,
1066 KEY_READ
| KEY_WRITE
, NULL
, &masks_key
, NULL
);
1067 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1068 for (i
=0; i
< list
->channelcount
; i
++)
1070 sprintfW(mask_valuename
, valuename_format
, i
);
1071 res
= RegSetValueExW(masks_key
, mask_valuename
, 0, REG_BINARY
,
1072 list
->channelmasks
[i
], mask_size
);
1073 if (res
!= ERROR_SUCCESS
) break;
1075 RegCloseKey(masks_key
);
1076 if (res
!= ERROR_SUCCESS
) goto error_close_clsid_key
;
1079 error_close_clsid_key
:
1080 RegCloseKey(clsid_key
);
1083 error_close_coclass_key
:
1084 RegCloseKey(instance_key
);
1085 RegCloseKey(formats_key
);
1086 RegCloseKey(coclass_key
);
1088 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
1091 /***********************************************************************
1092 * unregister_pixelformats
1094 static HRESULT
unregister_pixelformats(struct regsvr_pixelformat
const *list
)
1096 LONG res
= ERROR_SUCCESS
;
1102 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0,
1103 KEY_READ
| KEY_WRITE
, &coclass_key
);
1104 if (res
== ERROR_FILE_NOT_FOUND
) return S_OK
;
1106 if (res
== ERROR_SUCCESS
) {
1107 StringFromGUID2(&CATID_WICPixelFormats
, buf
, 39);
1108 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
1109 KEY_READ
| KEY_WRITE
, NULL
, &formats_key
, NULL
);
1110 if (res
== ERROR_SUCCESS
)
1112 res
= RegCreateKeyExW(formats_key
, instance_keyname
, 0, NULL
, 0,
1113 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
1114 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
1116 if (res
!= ERROR_SUCCESS
)
1117 RegCloseKey(coclass_key
);
1119 if (res
!= ERROR_SUCCESS
) goto error_return
;
1121 for (; res
== ERROR_SUCCESS
&& list
->clsid
; ++list
) {
1122 StringFromGUID2(list
->clsid
, buf
, 39);
1124 res
= RegDeleteTreeW(coclass_key
, buf
);
1125 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
1126 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
1128 res
= RegDeleteTreeW(instance_key
, buf
);
1129 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
1130 if (res
!= ERROR_SUCCESS
) goto error_close_coclass_key
;
1133 error_close_coclass_key
:
1134 RegCloseKey(instance_key
);
1135 RegCloseKey(formats_key
);
1136 RegCloseKey(coclass_key
);
1138 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
1141 /***********************************************************************
1144 static const BYTE mask_all
[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
1146 static const BYTE bmp_magic
[] = {0x42,0x4d};
1148 static GUID
const * const bmp_formats
[] = {
1149 &GUID_WICPixelFormat1bppIndexed
,
1150 &GUID_WICPixelFormat2bppIndexed
,
1151 &GUID_WICPixelFormat4bppIndexed
,
1152 &GUID_WICPixelFormat8bppIndexed
,
1153 &GUID_WICPixelFormat16bppBGR555
,
1154 &GUID_WICPixelFormat16bppBGR565
,
1155 &GUID_WICPixelFormat24bppBGR
,
1156 &GUID_WICPixelFormat32bppBGR
,
1157 &GUID_WICPixelFormat32bppBGRA
,
1161 static struct decoder_pattern
const bmp_patterns
[] = {
1162 {2,0,bmp_magic
,mask_all
,0},
1166 static const BYTE gif87a_magic
[6] = "GIF87a";
1167 static const BYTE gif89a_magic
[6] = "GIF89a";
1169 static GUID
const * const gif_formats
[] = {
1170 &GUID_WICPixelFormat8bppIndexed
,
1174 static struct decoder_pattern
const gif_patterns
[] = {
1175 {6,0,gif87a_magic
,mask_all
,0},
1176 {6,0,gif89a_magic
,mask_all
,0},
1180 static const BYTE ico_magic
[] = {00,00,01,00};
1182 static GUID
const * const ico_formats
[] = {
1183 &GUID_WICPixelFormat32bppBGRA
,
1187 static struct decoder_pattern
const ico_patterns
[] = {
1188 {4,0,ico_magic
,mask_all
,0},
1192 static const BYTE jpeg_magic
[] = {0xff, 0xd8};
1194 static GUID
const * const jpeg_formats
[] = {
1195 &GUID_WICPixelFormat24bppBGR
,
1196 &GUID_WICPixelFormat32bppCMYK
,
1197 &GUID_WICPixelFormat8bppGray
,
1201 static struct decoder_pattern
const jpeg_patterns
[] = {
1202 {2,0,jpeg_magic
,mask_all
,0},
1206 static const BYTE png_magic
[] = {137,80,78,71,13,10,26,10};
1208 static GUID
const * const png_formats
[] = {
1209 &GUID_WICPixelFormatBlackWhite
,
1210 &GUID_WICPixelFormat2bppGray
,
1211 &GUID_WICPixelFormat4bppGray
,
1212 &GUID_WICPixelFormat8bppGray
,
1213 &GUID_WICPixelFormat16bppGray
,
1214 &GUID_WICPixelFormat32bppBGRA
,
1215 &GUID_WICPixelFormat64bppRGBA
,
1216 &GUID_WICPixelFormat1bppIndexed
,
1217 &GUID_WICPixelFormat2bppIndexed
,
1218 &GUID_WICPixelFormat4bppIndexed
,
1219 &GUID_WICPixelFormat8bppIndexed
,
1220 &GUID_WICPixelFormat24bppBGR
,
1221 &GUID_WICPixelFormat48bppRGB
,
1225 static struct decoder_pattern
const png_patterns
[] = {
1226 {8,0,png_magic
,mask_all
,0},
1230 static const BYTE tiff_magic_le
[] = {0x49,0x49,42,0};
1231 static const BYTE tiff_magic_be
[] = {0x4d,0x4d,0,42};
1233 static GUID
const * const tiff_decode_formats
[] = {
1234 &GUID_WICPixelFormatBlackWhite
,
1235 &GUID_WICPixelFormat4bppGray
,
1236 &GUID_WICPixelFormat8bppGray
,
1237 &GUID_WICPixelFormat4bppIndexed
,
1238 &GUID_WICPixelFormat8bppIndexed
,
1239 &GUID_WICPixelFormat24bppBGR
,
1240 &GUID_WICPixelFormat32bppBGR
,
1241 &GUID_WICPixelFormat32bppBGRA
,
1242 &GUID_WICPixelFormat32bppPBGRA
,
1243 &GUID_WICPixelFormat48bppRGB
,
1244 &GUID_WICPixelFormat64bppRGBA
,
1245 &GUID_WICPixelFormat64bppPRGBA
,
1249 static struct decoder_pattern
const tiff_patterns
[] = {
1250 {4,0,tiff_magic_le
,mask_all
,0},
1251 {4,0,tiff_magic_be
,mask_all
,0},
1255 static const BYTE tga_footer_magic
[18] = "TRUEVISION-XFILE.";
1257 static const BYTE tga_indexed_magic
[18] = {0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0};
1258 static const BYTE tga_indexed_mask
[18] = {0,0xff,0xf7,0,0,0,0,0,0,0,0,0,0,0,0,0,0xff,0xcf};
1260 static const BYTE tga_truecolor_magic
[18] = {0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1261 static const BYTE tga_truecolor_mask
[18] = {0,0xff,0xf7,0,0,0,0,0,0,0,0,0,0,0,0,0,0x87,0xc0};
1263 static const BYTE tga_grayscale_magic
[18] = {0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0};
1264 static const BYTE tga_grayscale_mask
[18] = {0,0xff,0xf7,0,0,0,0,0,0,0,0,0,0,0,0,0,0xff,0xcf};
1266 static GUID
const * const tga_formats
[] = {
1267 &GUID_WICPixelFormat8bppGray
,
1268 &GUID_WICPixelFormat8bppIndexed
,
1269 &GUID_WICPixelFormat16bppGray
,
1270 &GUID_WICPixelFormat16bppBGR555
,
1271 &GUID_WICPixelFormat24bppBGR
,
1272 &GUID_WICPixelFormat32bppBGRA
,
1273 &GUID_WICPixelFormat32bppPBGRA
,
1277 static struct decoder_pattern
const tga_patterns
[] = {
1278 {18,18,tga_footer_magic
,mask_all
,1},
1279 {18,0,tga_indexed_magic
,tga_indexed_mask
,0},
1280 {18,0,tga_truecolor_magic
,tga_truecolor_mask
,0},
1281 {18,0,tga_grayscale_magic
,tga_grayscale_mask
,0},
1285 static struct regsvr_decoder
const decoder_list
[] = {
1286 { &CLSID_WICBmpDecoder
,
1290 &GUID_VendorMicrosoft
,
1291 &GUID_ContainerFormatBmp
,
1297 { &CLSID_WICGifDecoder
,
1301 &GUID_VendorMicrosoft
,
1302 &GUID_ContainerFormatGif
,
1308 { &CLSID_WICIcoDecoder
,
1312 &GUID_VendorMicrosoft
,
1313 &GUID_ContainerFormatIco
,
1314 "image/vnd.microsoft.icon",
1319 { &CLSID_WICJpegDecoder
,
1323 &GUID_VendorMicrosoft
,
1324 &GUID_ContainerFormatJpeg
,
1330 { &CLSID_WICPngDecoder
,
1334 &GUID_VendorMicrosoft
,
1335 &GUID_ContainerFormatPng
,
1341 { &CLSID_WICTiffDecoder
,
1345 &GUID_VendorMicrosoft
,
1346 &GUID_ContainerFormatTiff
,
1349 tiff_decode_formats
,
1352 { &CLSID_WineTgaDecoder
,
1357 &GUID_WineContainerFormatTga
,
1363 { NULL
} /* list terminator */
1366 static GUID
const * const bmp_encode_formats
[] = {
1367 &GUID_WICPixelFormat16bppBGR555
,
1368 &GUID_WICPixelFormat16bppBGR565
,
1369 &GUID_WICPixelFormat24bppBGR
,
1370 &GUID_WICPixelFormat32bppBGR
,
1374 static GUID
const * const png_encode_formats
[] = {
1375 &GUID_WICPixelFormat24bppBGR
,
1376 &GUID_WICPixelFormatBlackWhite
,
1377 &GUID_WICPixelFormat2bppGray
,
1378 &GUID_WICPixelFormat4bppGray
,
1379 &GUID_WICPixelFormat8bppGray
,
1380 &GUID_WICPixelFormat16bppGray
,
1381 &GUID_WICPixelFormat32bppBGR
,
1382 &GUID_WICPixelFormat32bppBGRA
,
1383 &GUID_WICPixelFormat48bppRGB
,
1384 &GUID_WICPixelFormat64bppRGBA
,
1388 static GUID
const * const tiff_encode_formats
[] = {
1389 &GUID_WICPixelFormatBlackWhite
,
1390 &GUID_WICPixelFormat4bppGray
,
1391 &GUID_WICPixelFormat8bppGray
,
1392 &GUID_WICPixelFormat24bppBGR
,
1393 &GUID_WICPixelFormat32bppBGRA
,
1394 &GUID_WICPixelFormat32bppPBGRA
,
1395 &GUID_WICPixelFormat48bppRGB
,
1396 &GUID_WICPixelFormat64bppRGBA
,
1397 &GUID_WICPixelFormat64bppPRGBA
,
1401 static GUID
const * const icns_encode_formats
[] = {
1402 &GUID_WICPixelFormat32bppBGRA
,
1406 static struct regsvr_encoder
const encoder_list
[] = {
1407 { &CLSID_WICBmpEncoder
,
1411 &GUID_VendorMicrosoft
,
1412 &GUID_ContainerFormatBmp
,
1417 { &CLSID_WICJpegEncoder
,
1421 &GUID_VendorMicrosoft
,
1422 &GUID_ContainerFormatJpeg
,
1427 { &CLSID_WICPngEncoder
,
1431 &GUID_VendorMicrosoft
,
1432 &GUID_ContainerFormatPng
,
1437 { &CLSID_WICTiffEncoder
,
1441 &GUID_VendorMicrosoft
,
1442 &GUID_ContainerFormatTiff
,
1447 { &CLSID_WICIcnsEncoder
,
1452 NULL
, /* no container format guid */
1457 { NULL
} /* list terminator */
1460 static GUID
const * const converter_formats
[] = {
1461 &GUID_WICPixelFormat1bppIndexed
,
1462 &GUID_WICPixelFormat2bppIndexed
,
1463 &GUID_WICPixelFormat4bppIndexed
,
1464 &GUID_WICPixelFormat8bppIndexed
,
1465 &GUID_WICPixelFormatBlackWhite
,
1466 &GUID_WICPixelFormat2bppGray
,
1467 &GUID_WICPixelFormat4bppGray
,
1468 &GUID_WICPixelFormat8bppGray
,
1469 &GUID_WICPixelFormat16bppGray
,
1470 &GUID_WICPixelFormat16bppBGR555
,
1471 &GUID_WICPixelFormat16bppBGR565
,
1472 &GUID_WICPixelFormat16bppBGRA5551
,
1473 &GUID_WICPixelFormat24bppBGR
,
1474 &GUID_WICPixelFormat32bppBGR
,
1475 &GUID_WICPixelFormat32bppBGRA
,
1476 &GUID_WICPixelFormat32bppPBGRA
,
1477 &GUID_WICPixelFormat48bppRGB
,
1478 &GUID_WICPixelFormat64bppRGBA
,
1479 &GUID_WICPixelFormat32bppCMYK
,
1483 static struct regsvr_converter
const converter_list
[] = {
1484 { &CLSID_WICDefaultFormatConverter
,
1486 "Default Pixel Format Converter",
1488 &GUID_VendorMicrosoft
,
1491 { NULL
} /* list terminator */
1494 static const BYTE no_magic
[1] = { 0 };
1495 static const BYTE no_mask
[1] = { 0 };
1497 static const struct metadata_pattern ifd_metadata_pattern
[] = {
1498 { 0, 1, no_magic
, no_mask
, 0 },
1502 static const struct reader_containers ifd_containers
[] = {
1504 &GUID_ContainerFormatTiff
,
1505 ifd_metadata_pattern
1507 { NULL
} /* list terminator */
1510 static const BYTE tEXt
[] = "tEXt";
1512 static const struct metadata_pattern pngtext_metadata_pattern
[] = {
1513 { 4, 4, tEXt
, mask_all
, 4 },
1517 static const struct reader_containers pngtext_containers
[] = {
1519 &GUID_ContainerFormatPng
,
1520 pngtext_metadata_pattern
1522 { NULL
} /* list terminator */
1525 static const struct metadata_pattern lsd_metadata_patterns
[] = {
1526 { 0, 6, gif87a_magic
, mask_all
, 0 },
1527 { 0, 6, gif89a_magic
, mask_all
, 0 },
1531 static const struct reader_containers lsd_containers
[] = {
1533 &GUID_ContainerFormatGif
,
1534 lsd_metadata_patterns
1536 { NULL
} /* list terminator */
1539 static const BYTE imd_magic
[] = { 0x2c };
1541 static const struct metadata_pattern imd_metadata_pattern
[] = {
1542 { 0, 1, imd_magic
, mask_all
, 1 },
1546 static const struct reader_containers imd_containers
[] = {
1548 &GUID_ContainerFormatGif
,
1549 imd_metadata_pattern
1551 { NULL
} /* list terminator */
1554 static const BYTE gce_magic
[] = { 0x21, 0xf9, 0x04 };
1556 static const struct metadata_pattern gce_metadata_pattern
[] = {
1557 { 0, 3, gce_magic
, mask_all
, 3 },
1561 static const struct reader_containers gce_containers
[] = {
1563 &GUID_ContainerFormatGif
,
1564 gce_metadata_pattern
1566 { NULL
} /* list terminator */
1569 static const BYTE ape_magic
[] = { 0x21, 0xff, 0x0b };
1571 static const struct metadata_pattern ape_metadata_pattern
[] = {
1572 { 0, 3, ape_magic
, mask_all
, 0 },
1576 static const struct reader_containers ape_containers
[] = {
1578 &GUID_ContainerFormatGif
,
1579 ape_metadata_pattern
1581 { NULL
} /* list terminator */
1584 static const BYTE gif_comment_magic
[] = { 0x21, 0xfe };
1586 static const struct metadata_pattern gif_comment_metadata_pattern
[] = {
1587 { 0, 2, gif_comment_magic
, mask_all
, 0 },
1591 static const struct reader_containers gif_comment_containers
[] = {
1593 &GUID_ContainerFormatGif
,
1594 gif_comment_metadata_pattern
1596 { NULL
} /* list terminator */
1599 static struct regsvr_metadatareader
const metadatareader_list
[] = {
1600 { &CLSID_WICUnknownMetadataReader
,
1602 "Unknown Metadata Reader",
1605 &GUID_VendorMicrosoft
,
1606 &GUID_MetadataFormatUnknown
,
1610 { &CLSID_WICIfdMetadataReader
,
1615 &GUID_VendorMicrosoft
,
1616 &GUID_MetadataFormatIfd
,
1620 { &CLSID_WICPngTextMetadataReader
,
1622 "Chunk tEXt Reader",
1625 &GUID_VendorMicrosoft
,
1626 &GUID_MetadataFormatChunktEXt
,
1630 { &CLSID_WICLSDMetadataReader
,
1632 "Logical Screen Descriptor Reader",
1635 &GUID_VendorMicrosoft
,
1636 &GUID_MetadataFormatLSD
,
1640 { &CLSID_WICIMDMetadataReader
,
1642 "Image Descriptor Reader",
1645 &GUID_VendorMicrosoft
,
1646 &GUID_MetadataFormatIMD
,
1650 { &CLSID_WICGCEMetadataReader
,
1652 "Graphic Control Extension Reader",
1655 &GUID_VendorMicrosoft
,
1656 &GUID_MetadataFormatGCE
,
1660 { &CLSID_WICAPEMetadataReader
,
1662 "Application Extension Reader",
1665 &GUID_VendorMicrosoft
,
1666 &GUID_MetadataFormatAPE
,
1670 { &CLSID_WICGifCommentMetadataReader
,
1672 "Comment Extension Reader",
1675 &GUID_VendorMicrosoft
,
1676 &GUID_MetadataFormatGifComment
,
1678 gif_comment_containers
1680 { NULL
} /* list terminator */
1683 static BYTE
const channel_mask_1bit
[] = { 0x01 };
1684 static BYTE
const channel_mask_2bit
[] = { 0x03 };
1685 static BYTE
const channel_mask_4bit
[] = { 0x0f };
1687 static BYTE
const channel_mask_8bit
[] = { 0xff, 0x00, 0x00, 0x00 };
1688 static BYTE
const channel_mask_8bit2
[] = { 0x00, 0xff, 0x00, 0x00 };
1689 static BYTE
const channel_mask_8bit3
[] = { 0x00, 0x00, 0xff, 0x00 };
1690 static BYTE
const channel_mask_8bit4
[] = { 0x00, 0x00, 0x00, 0xff };
1692 static BYTE
const channel_mask_16bit
[] = { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
1693 static BYTE
const channel_mask_16bit2
[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 };
1694 static BYTE
const channel_mask_16bit3
[] = { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
1695 static BYTE
const channel_mask_16bit4
[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff };
1697 static BYTE
const channel_mask_5bit
[] = { 0x1f, 0x00 };
1698 static BYTE
const channel_mask_5bit2
[] = { 0xe0, 0x03 };
1699 static BYTE
const channel_mask_5bit3
[] = { 0x00, 0x7c };
1700 static BYTE
const channel_mask_5bit4
[] = { 0x00, 0x80 };
1702 static BYTE
const channel_mask_BGR565_2
[] = { 0xe0, 0x07 };
1703 static BYTE
const channel_mask_BGR565_3
[] = { 0x00, 0xf8 };
1705 static BYTE
const * const channel_masks_1bit
[] = { channel_mask_1bit
};
1706 static BYTE
const * const channel_masks_2bit
[] = { channel_mask_2bit
};
1707 static BYTE
const * const channel_masks_4bit
[] = { channel_mask_4bit
};
1708 static BYTE
const * const channel_masks_8bit
[] = { channel_mask_8bit
,
1709 channel_mask_8bit2
, channel_mask_8bit3
, channel_mask_8bit4
};
1710 static BYTE
const * const channel_masks_16bit
[] = { channel_mask_16bit
,
1711 channel_mask_16bit2
, channel_mask_16bit3
, channel_mask_16bit4
};
1713 static BYTE
const * const channel_masks_BGRA5551
[] = { channel_mask_5bit
,
1714 channel_mask_5bit2
, channel_mask_5bit3
, channel_mask_5bit4
};
1716 static BYTE
const * const channel_masks_BGR565
[] = { channel_mask_5bit
,
1717 channel_mask_BGR565_2
, channel_mask_BGR565_3
};
1719 static struct regsvr_pixelformat
const pixelformat_list
[] = {
1720 { &GUID_WICPixelFormat1bppIndexed
,
1723 NULL
, /* no version */
1724 &GUID_VendorMicrosoft
,
1725 1, /* bitsperpixel */
1726 1, /* channel count */
1728 WICPixelFormatNumericRepresentationIndexed
,
1731 { &GUID_WICPixelFormat2bppIndexed
,
1734 NULL
, /* no version */
1735 &GUID_VendorMicrosoft
,
1736 2, /* bitsperpixel */
1737 1, /* channel count */
1739 WICPixelFormatNumericRepresentationIndexed
,
1742 { &GUID_WICPixelFormat4bppIndexed
,
1745 NULL
, /* no version */
1746 &GUID_VendorMicrosoft
,
1747 4, /* bitsperpixel */
1748 1, /* channel count */
1750 WICPixelFormatNumericRepresentationIndexed
,
1753 { &GUID_WICPixelFormat8bppIndexed
,
1756 NULL
, /* no version */
1757 &GUID_VendorMicrosoft
,
1758 8, /* bitsperpixel */
1759 1, /* channel count */
1761 WICPixelFormatNumericRepresentationIndexed
,
1764 { &GUID_WICPixelFormatBlackWhite
,
1767 NULL
, /* no version */
1768 &GUID_VendorMicrosoft
,
1769 1, /* bitsperpixel */
1770 1, /* channel count */
1772 WICPixelFormatNumericRepresentationUnsignedInteger
,
1775 { &GUID_WICPixelFormat2bppGray
,
1778 NULL
, /* no version */
1779 &GUID_VendorMicrosoft
,
1780 2, /* bitsperpixel */
1781 1, /* channel count */
1783 WICPixelFormatNumericRepresentationUnsignedInteger
,
1786 { &GUID_WICPixelFormat4bppGray
,
1789 NULL
, /* no version */
1790 &GUID_VendorMicrosoft
,
1791 4, /* bitsperpixel */
1792 1, /* channel count */
1794 WICPixelFormatNumericRepresentationUnsignedInteger
,
1797 { &GUID_WICPixelFormat8bppGray
,
1800 NULL
, /* no version */
1801 &GUID_VendorMicrosoft
,
1802 8, /* bitsperpixel */
1803 1, /* channel count */
1805 WICPixelFormatNumericRepresentationUnsignedInteger
,
1808 { &GUID_WICPixelFormat16bppGray
,
1811 NULL
, /* no version */
1812 &GUID_VendorMicrosoft
,
1813 16, /* bitsperpixel */
1814 1, /* channel count */
1815 channel_masks_16bit
,
1816 WICPixelFormatNumericRepresentationUnsignedInteger
,
1819 { &GUID_WICPixelFormat16bppBGR555
,
1822 NULL
, /* no version */
1823 &GUID_VendorMicrosoft
,
1824 16, /* bitsperpixel */
1825 3, /* channel count */
1826 channel_masks_BGRA5551
,
1827 WICPixelFormatNumericRepresentationUnsignedInteger
,
1830 { &GUID_WICPixelFormat16bppBGR565
,
1833 NULL
, /* no version */
1834 &GUID_VendorMicrosoft
,
1835 16, /* bitsperpixel */
1836 3, /* channel count */
1837 channel_masks_BGR565
,
1838 WICPixelFormatNumericRepresentationUnsignedInteger
,
1841 { &GUID_WICPixelFormat16bppBGRA5551
,
1844 NULL
, /* no version */
1845 &GUID_VendorMicrosoft
,
1846 16, /* bitsperpixel */
1847 4, /* channel count */
1848 channel_masks_BGRA5551
,
1849 WICPixelFormatNumericRepresentationUnsignedInteger
,
1852 { &GUID_WICPixelFormat24bppBGR
,
1855 NULL
, /* no version */
1856 &GUID_VendorMicrosoft
,
1857 24, /* bitsperpixel */
1858 3, /* channel count */
1860 WICPixelFormatNumericRepresentationUnsignedInteger
,
1863 { &GUID_WICPixelFormat32bppBGR
,
1866 NULL
, /* no version */
1867 &GUID_VendorMicrosoft
,
1868 32, /* bitsperpixel */
1869 3, /* channel count */
1871 WICPixelFormatNumericRepresentationUnsignedInteger
,
1874 { &GUID_WICPixelFormat32bppBGRA
,
1877 NULL
, /* no version */
1878 &GUID_VendorMicrosoft
,
1879 32, /* bitsperpixel */
1880 4, /* channel count */
1882 WICPixelFormatNumericRepresentationUnsignedInteger
,
1885 { &GUID_WICPixelFormat32bppPBGRA
,
1888 NULL
, /* no version */
1889 &GUID_VendorMicrosoft
,
1890 32, /* bitsperpixel */
1891 4, /* channel count */
1893 WICPixelFormatNumericRepresentationUnsignedInteger
,
1896 { &GUID_WICPixelFormat48bppRGB
,
1899 NULL
, /* no version */
1900 &GUID_VendorMicrosoft
,
1901 48, /* bitsperpixel */
1902 3, /* channel count */
1903 channel_masks_16bit
,
1904 WICPixelFormatNumericRepresentationUnsignedInteger
,
1907 { &GUID_WICPixelFormat64bppRGBA
,
1910 NULL
, /* no version */
1911 &GUID_VendorMicrosoft
,
1912 64, /* bitsperpixel */
1913 4, /* channel count */
1914 channel_masks_16bit
,
1915 WICPixelFormatNumericRepresentationUnsignedInteger
,
1918 { &GUID_WICPixelFormat64bppPRGBA
,
1921 NULL
, /* no version */
1922 &GUID_VendorMicrosoft
,
1923 64, /* bitsperpixel */
1924 4, /* channel count */
1925 channel_masks_16bit
,
1926 WICPixelFormatNumericRepresentationUnsignedInteger
,
1929 { &GUID_WICPixelFormat32bppCMYK
,
1932 NULL
, /* no version */
1933 &GUID_VendorMicrosoft
,
1934 32, /* bitsperpixel */
1935 4, /* channel count */
1937 WICPixelFormatNumericRepresentationUnsignedInteger
,
1940 { NULL
} /* list terminator */
1943 struct regsvr_category
1945 const CLSID
*clsid
; /* NULL for end of list */
1948 static const struct regsvr_category category_list
[] = {
1949 { &CATID_WICBitmapDecoders
},
1950 { &CATID_WICBitmapEncoders
},
1951 { &CATID_WICFormatConverters
},
1952 { &CATID_WICMetadataReader
},
1953 { &CATID_WICPixelFormats
},
1957 static HRESULT
register_categories(const struct regsvr_category
*list
)
1961 HKEY coclass_key
, categories_key
, instance_key
;
1963 res
= RegCreateKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0, NULL
, 0,
1964 KEY_READ
| KEY_WRITE
, NULL
, &coclass_key
, NULL
);
1965 if (res
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(res
);
1967 StringFromGUID2(&CLSID_WICImagingCategories
, buf
, 39);
1968 res
= RegCreateKeyExW(coclass_key
, buf
, 0, NULL
, 0,
1969 KEY_READ
| KEY_WRITE
, NULL
, &categories_key
, NULL
);
1970 if (res
!= ERROR_SUCCESS
)
1972 RegCloseKey(coclass_key
);
1973 return HRESULT_FROM_WIN32(res
);
1976 res
= RegCreateKeyExW(categories_key
, instance_keyname
, 0, NULL
, 0,
1977 KEY_READ
| KEY_WRITE
, NULL
, &instance_key
, NULL
);
1979 for (; res
== ERROR_SUCCESS
&& list
->clsid
; list
++)
1981 HKEY instance_clsid_key
;
1983 StringFromGUID2(list
->clsid
, buf
, 39);
1984 res
= RegCreateKeyExW(instance_key
, buf
, 0, NULL
, 0,
1985 KEY_READ
| KEY_WRITE
, NULL
, &instance_clsid_key
, NULL
);
1986 if (res
== ERROR_SUCCESS
)
1988 res
= RegSetValueExW(instance_clsid_key
, clsid_valuename
, 0, REG_SZ
,
1989 (const BYTE
*)buf
, 78);
1990 RegCloseKey(instance_clsid_key
);
1994 RegCloseKey(instance_key
);
1995 RegCloseKey(categories_key
);
1996 RegCloseKey(coclass_key
);
1998 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
2001 static HRESULT
unregister_categories(const struct regsvr_category
*list
)
2005 HKEY coclass_key
, categories_key
, instance_key
;
2007 res
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, clsid_keyname
, 0,
2008 KEY_READ
| KEY_WRITE
, &coclass_key
);
2009 if (res
!= ERROR_SUCCESS
) return HRESULT_FROM_WIN32(res
);
2011 StringFromGUID2(&CLSID_WICImagingCategories
, buf
, 39);
2012 res
= RegOpenKeyExW(coclass_key
, buf
, 0,
2013 KEY_READ
| KEY_WRITE
, &categories_key
);
2014 if (res
!= ERROR_SUCCESS
)
2016 if (res
== ERROR_FILE_NOT_FOUND
) res
= ERROR_SUCCESS
;
2017 RegCloseKey(coclass_key
);
2018 return HRESULT_FROM_WIN32(res
);
2021 res
= RegOpenKeyExW(categories_key
, instance_keyname
, 0,
2022 KEY_READ
| KEY_WRITE
, &instance_key
);
2024 for (; res
== ERROR_SUCCESS
&& list
->clsid
; list
++)
2026 StringFromGUID2(list
->clsid
, buf
, 39);
2027 res
= RegDeleteTreeW(instance_key
, buf
);
2030 RegCloseKey(instance_key
);
2031 RegCloseKey(categories_key
);
2033 StringFromGUID2(&CLSID_WICImagingCategories
, buf
, 39);
2034 res
= RegDeleteTreeW(coclass_key
, buf
);
2036 RegCloseKey(coclass_key
);
2038 return res
!= ERROR_SUCCESS
? HRESULT_FROM_WIN32(res
) : S_OK
;
2041 extern HRESULT WINAPI
WIC_DllRegisterServer(void) DECLSPEC_HIDDEN
;
2042 extern HRESULT WINAPI
WIC_DllUnregisterServer(void) DECLSPEC_HIDDEN
;
2044 HRESULT WINAPI
DllRegisterServer(void)
2050 hr
= WIC_DllRegisterServer();
2052 hr
= register_categories(category_list
);
2054 hr
= register_decoders(decoder_list
);
2056 hr
= register_encoders(encoder_list
);
2058 hr
= register_converters(converter_list
);
2060 hr
= register_metadatareaders(metadatareader_list
);
2062 hr
= register_pixelformats(pixelformat_list
);
2066 HRESULT WINAPI
DllUnregisterServer(void)
2072 hr
= WIC_DllUnregisterServer();
2074 hr
= unregister_categories(category_list
);
2076 hr
= unregister_decoders(decoder_list
);
2078 hr
= unregister_encoders(encoder_list
);
2080 hr
= unregister_converters(converter_list
);
2082 hr
= unregister_metadatareaders(metadatareader_list
);
2084 hr
= unregister_pixelformats(pixelformat_list
);