From 779f88ec904aa3b8270a88a21307915b9c44c3c1 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 13 Dec 2010 17:58:31 +0100 Subject: [PATCH] windowscodecs: Convert the coclasses registration to the IRegistrar mechanism. --- dlls/windowscodecs/Makefile.in | 6 +- dlls/windowscodecs/regsvr.c | 322 ------------------ dlls/windowscodecs/windowscodecs_wincodec.idl | 84 +++++ 3 files changed, 87 insertions(+), 325 deletions(-) diff --git a/dlls/windowscodecs/Makefile.in b/dlls/windowscodecs/Makefile.in index 9dd9302329..bc61cb49b0 100644 --- a/dlls/windowscodecs/Makefile.in +++ b/dlls/windowscodecs/Makefile.in @@ -2,7 +2,7 @@ MODULE = windowscodecs.dll IMPORTLIB = windowscodecs IMPORTS = uuid ole32 oleaut32 shlwapi advapi32 rpcrt4 EXTRAINCL = @PNGINCL@ -EXTRADEFS = -DENTRY_PREFIX=WIC_ -DPROXY_DELEGATION -DREGISTER_PROXY_DLL +EXTRADEFS = -DENTRY_PREFIX=WIC_ -DPROXY_DELEGATION -DWINE_REGISTER_DLL C_SRCS = \ bmpdecode.c \ @@ -28,8 +28,8 @@ C_SRCS = \ RC_SRCS = version.rc -IDL_P_SRCS = \ - windowscodecs_wincodec.idl +IDL_P_SRCS = windowscodecs_wincodec.idl +IDL_R_SRCS = windowscodecs_wincodec.idl EXTRA_OBJS = dlldata.o diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index 6066724a51..e6a197081c 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -43,21 +43,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); /*********************************************************************** * interface for self-registering */ -struct regsvr_coclass -{ - CLSID const *clsid; /* NULL for end of list */ - LPCSTR name; /* can be NULL to omit */ - LPCSTR ips; /* can be NULL to omit */ - LPCSTR ips32; /* can be NULL to omit */ - LPCSTR ips32_tmodel; /* can be NULL to omit */ - LPCSTR progid; /* can be NULL to omit */ - LPCSTR viprogid; /* can be NULL to omit */ - LPCSTR progid_extra; /* can be NULL to omit */ -}; - -static HRESULT register_coclasses(struct regsvr_coclass const *list); -static HRESULT unregister_coclasses(struct regsvr_coclass const *list); - struct decoder_pattern { DWORD length; /* 0 for end of list */ @@ -148,139 +133,6 @@ static char const mask_valuename[] = "Mask"; static char const endofstream_valuename[] = "EndOfStream"; static WCHAR const pixelformats_keyname[] = {'P','i','x','e','l','F','o','r','m','a','t','s',0}; -/*********************************************************************** - * static helper functions - */ -static LONG register_key_defvalueW(HKEY base, WCHAR const *name, - WCHAR const *value); -static LONG register_key_defvalueA(HKEY base, WCHAR const *name, - char const *value); -static LONG register_progid(WCHAR const *clsid, - char const *progid, char const *curver_progid, - char const *name, char const *extra); - -/*********************************************************************** - * register_coclasses - */ -static HRESULT register_coclasses(struct regsvr_coclass const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY coclass_key; - - res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL); - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->clsid; ++list) { - WCHAR buf[39]; - HKEY clsid_key; - - StringFromGUID2(list->clsid, buf, 39); - res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_coclass_key; - - if (list->name) { - res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ, - (CONST BYTE*)(list->name), - strlen(list->name) + 1); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->ips) { - res = register_key_defvalueA(clsid_key, ips_keyname, list->ips); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->ips32) { - HKEY ips32_key; - - res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, - &ips32_key, NULL); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - - res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ, - (CONST BYTE*)list->ips32, - lstrlenA(list->ips32) + 1); - if (res == ERROR_SUCCESS && list->ips32_tmodel) - res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ, - (CONST BYTE*)list->ips32_tmodel, - strlen(list->ips32_tmodel) + 1); - RegCloseKey(ips32_key); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->progid) { - res = register_key_defvalueA(clsid_key, progid_keyname, - list->progid); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - - res = register_progid(buf, list->progid, NULL, - list->name, list->progid_extra); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - if (list->viprogid) { - res = register_key_defvalueA(clsid_key, viprogid_keyname, - list->viprogid); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - - res = register_progid(buf, list->viprogid, list->progid, - list->name, list->progid_extra); - if (res != ERROR_SUCCESS) goto error_close_clsid_key; - } - - error_close_clsid_key: - RegCloseKey(clsid_key); - } - -error_close_coclass_key: - RegCloseKey(coclass_key); -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - -/*********************************************************************** - * unregister_coclasses - */ -static HRESULT unregister_coclasses(struct regsvr_coclass const *list) -{ - LONG res = ERROR_SUCCESS; - HKEY coclass_key; - - res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, - KEY_READ | KEY_WRITE, &coclass_key); - if (res == ERROR_FILE_NOT_FOUND) return S_OK; - if (res != ERROR_SUCCESS) goto error_return; - - for (; res == ERROR_SUCCESS && list->clsid; ++list) { - WCHAR buf[39]; - - StringFromGUID2(list->clsid, buf, 39); - res = RegDeleteTreeW(coclass_key, buf); - if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS; - if (res != ERROR_SUCCESS) goto error_close_coclass_key; - - if (list->progid) { - res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->progid); - if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS; - if (res != ERROR_SUCCESS) goto error_close_coclass_key; - } - - if (list->viprogid) { - res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->viprogid); - if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS; - if (res != ERROR_SUCCESS) goto error_close_coclass_key; - } - } - -error_close_coclass_key: - RegCloseKey(coclass_key); -error_return: - return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; -} - /*********************************************************************** * register_decoders */ @@ -817,176 +669,6 @@ error_return: return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK; } -/*********************************************************************** - * register_key_defvalueW - */ -static LONG register_key_defvalueW( - HKEY base, - WCHAR const *name, - WCHAR const *value) -{ - LONG res; - HKEY key; - - res = RegCreateKeyExW(base, name, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &key, NULL); - if (res != ERROR_SUCCESS) return res; - res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value, - (lstrlenW(value) + 1) * sizeof(WCHAR)); - RegCloseKey(key); - return res; -} - -/*********************************************************************** - * register_key_defvalueA - */ -static LONG register_key_defvalueA( - HKEY base, - WCHAR const *name, - char const *value) -{ - LONG res; - HKEY key; - - res = RegCreateKeyExW(base, name, 0, NULL, 0, - KEY_READ | KEY_WRITE, NULL, &key, NULL); - if (res != ERROR_SUCCESS) return res; - res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value, - lstrlenA(value) + 1); - RegCloseKey(key); - return res; -} - -/*********************************************************************** - * register_progid - */ -static LONG register_progid( - WCHAR const *clsid, - char const *progid, - char const *curver_progid, - char const *name, - char const *extra) -{ - LONG res; - HKEY progid_key; - - res = RegCreateKeyExA(HKEY_CLASSES_ROOT, progid, 0, - NULL, 0, KEY_READ | KEY_WRITE, NULL, - &progid_key, NULL); - if (res != ERROR_SUCCESS) return res; - - if (name) { - res = RegSetValueExA(progid_key, NULL, 0, REG_SZ, - (CONST BYTE*)name, strlen(name) + 1); - if (res != ERROR_SUCCESS) goto error_close_progid_key; - } - - if (clsid) { - res = register_key_defvalueW(progid_key, clsid_keyname, clsid); - if (res != ERROR_SUCCESS) goto error_close_progid_key; - } - - if (curver_progid) { - res = register_key_defvalueA(progid_key, curver_keyname, - curver_progid); - if (res != ERROR_SUCCESS) goto error_close_progid_key; - } - - if (extra) { - HKEY extra_key; - - res = RegCreateKeyExA(progid_key, extra, 0, - NULL, 0, KEY_READ | KEY_WRITE, NULL, - &extra_key, NULL); - if (res == ERROR_SUCCESS) - RegCloseKey(extra_key); - } - -error_close_progid_key: - RegCloseKey(progid_key); - return res; -} - -/*********************************************************************** - * coclass list - */ -static struct regsvr_coclass const coclass_list[] = { - { &CLSID_WICImagingFactory, - "WIC Imaging Factory", - NULL, - "windowscodecs.dll", - "Both" - }, - { &CLSID_WICBmpDecoder, - "WIC BMP Decoder", - NULL, - "windowscodecs.dll", - "Both" - }, - { &CLSID_WICPngDecoder, - "WIC PNG Decoder", - NULL, - "windowscodecs.dll", - "Both" - }, - { &CLSID_WICPngEncoder, - "WIC PNG Encoder", - NULL, - "windowscodecs.dll", - "Both" - }, - { &CLSID_WICBmpEncoder, - "WIC BMP Encoder", - NULL, - "windowscodecs.dll", - "Apartment" - }, - { &CLSID_WICGifDecoder, - "WIC GIF Decoder", - NULL, - "windowscodecs.dll", - "Both" - }, - { &CLSID_WICIcoDecoder, - "WIC ICO Decoder", - NULL, - "windowscodecs.dll", - "Both" - }, - { &CLSID_WICJpegDecoder, - "WIC JPEG Decoder", - NULL, - "windowscodecs.dll", - "Both" - }, - { &CLSID_WICTiffDecoder, - "WIC TIFF Decoder", - NULL, - "windowscodecs.dll", - "Both" - }, - { - &CLSID_WICIcnsEncoder, - "WIC ICNS Encoder", - NULL, - "windowscodecs.dll", - "Both" - }, - { &CLSID_WICDefaultFormatConverter, - "WIC Default Format Converter", - NULL, - "windowscodecs.dll", - "Both" - }, - { &CLSID_WineTgaDecoder, - "WIC TGA Decoder", - NULL, - "windowscodecs.dll", - "Both" - }, - { NULL } /* list terminator */ -}; - /*********************************************************************** * decoder list */ @@ -1305,8 +987,6 @@ HRESULT WINAPI DllRegisterServer(void) TRACE("\n"); hr = WIC_DllRegisterServer(); - if (SUCCEEDED(hr)) - hr = register_coclasses(coclass_list); if (SUCCEEDED(hr)) register_decoders(decoder_list); if (SUCCEEDED(hr)) @@ -1323,8 +1003,6 @@ HRESULT WINAPI DllUnregisterServer(void) TRACE("\n"); hr = WIC_DllUnregisterServer(); - if (SUCCEEDED(hr)) - hr = unregister_coclasses(coclass_list); if (SUCCEEDED(hr)) unregister_decoders(decoder_list); if (SUCCEEDED(hr)) diff --git a/dlls/windowscodecs/windowscodecs_wincodec.idl b/dlls/windowscodecs/windowscodecs_wincodec.idl index 33b47745af..853592c27f 100644 --- a/dlls/windowscodecs/windowscodecs_wincodec.idl +++ b/dlls/windowscodecs/windowscodecs_wincodec.idl @@ -17,3 +17,87 @@ */ #include "wincodec.idl" + +[ + helpstring("WIC Imaging Factory"), + threading(both), + uuid(cacaf262-9370-4615-a13b-9f5539da4c0a) +] +coclass WICImagingFactory { interface IWICImagingFactory; } + +[ + helpstring("WIC BMP Decoder"), + threading(both), + uuid(6b462062-7cbf-400d-9fdb-813dd10f2778) +] +coclass WICBmpDecoder { interface IWICBitmapDecoder; } + +[ + helpstring("WIC PNG Decoder"), + threading(both), + uuid(389ea17b-5078-4cde-b6ef-25c15175c751) +] +coclass WICPngDecoder { interface IWICBitmapDecoder; } + +[ + helpstring("WIC PNG Encoder"), + threading(both), + uuid(27949969-876a-41d7-9447-568f6a35a4dc) +] +coclass WICPngEncoder { interface IWICBitmapEncoder; } + +[ + helpstring("WIC BMP Encoder"), + threading(apartment), + uuid(69be8bb4-d66d-47c8-865a-ed1589433782) +] +coclass WICBmpEncoder { interface IWICBitmapEncoder; } + +[ + helpstring("WIC GIF Decoder"), + threading(both), + uuid(381dda3c-9ce9-4834-a23e-1f98f8fc52be) +] +coclass WICGifDecoder { interface IWICBitmapDecoder; } + +[ + helpstring("WIC ICO Decoder"), + threading(both), + uuid(c61bfcdf-2e0f-4aad-a8d7-e06bafebcdfe) +] +coclass WICIcoDecoder { interface IWICBitmapDecoder; } + +[ + helpstring("WIC JPEG Decoder"), + threading(both), + uuid(9456a480-e88b-43ea-9e73-0b2d9b71b1ca) +] +coclass WICJpegDecoder { interface IWICBitmapDecoder; } + +[ + helpstring("WIC TIFF Decoder"), + threading(both), + uuid(b54e85d9-fe23-499f-8b88-6acea713752b) +] +coclass WICTiffDecoder { interface IWICBitmapDecoder; } + +[ + helpstring("WIC ICNS Encoder"), + threading(both), + uuid(312fb6f1-b767-409d-8a6d-0fc154d4f05c) +] +coclass WICIcnsEncoder { interface IWICBitmapEncoder; } + +[ + helpstring("WIC Default Format Converter"), + threading(both), + uuid(1a3f11dc-b514-4b17-8c5f-2154513852f1) +] +coclass WICDefaultFormatConverter { interface IWICFormatConverter; } + +[ + helpstring("WIC TGA Decoder"), + threading(both), + uuid(b11fc79a-67cc-43e6-a9ce-e3d54945d304) +] +coclass WineTgaDecoder { interface IWICBitmapDecoder; } -- 2.32.0.93.g670b81a890