urlmon: Unregister window class on DLL unload.

Alexandre Julliard julliard at winehq.org
Thu Feb 13 10:48:28 CST 2014


Jacek Caban <jacek at codeweavers.com> writes:

> @@ -83,15 +83,50 @@ static LRESULT WINAPI notif_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
>      return DefWindowProcW(hwnd, msg, wParam, lParam);
>  }
>  
> +static const WCHAR wszURLMonikerNotificationWindow[] =
> +    {'U','R','L',' ','M','o','n','i','k','e','r',' ',
> +     'N','o','t','i','f','i','c','a','t','i','o','n',' ','W','i','n','d','o','w',0};
> +
> +static ATOM notif_wnd_class;
> +
> +static CRITICAL_SECTION notif_wnd_class_cs;
> +static CRITICAL_SECTION_DEBUG notif_wnd_class_cs_dbg = {
> +    0, 0, &notif_wnd_class_cs,
> +    { &notif_wnd_class_cs_dbg.ProcessLocksList, &notif_wnd_class_cs_dbg.ProcessLocksList },
> +    0, 0, { (DWORD_PTR)(__FILE__ ": notif_wnd_class") }
> +};
> +static CRITICAL_SECTION notif_wnd_class_cs = { &notif_wnd_class_cs_dbg, -1, 0, 0, 0, 0 };
> +
> +static BOOL ensure_notif_wnd_class(void)
> +{
> +    EnterCriticalSection(&notif_wnd_class_cs);
> +
> +    if(!notif_wnd_class) {
> +        static WNDCLASSEXW wndclass = {
> +            sizeof(wndclass), 0, notif_wnd_proc, 0, 0,
> +            NULL, NULL, NULL, NULL, NULL,
> +            wszURLMonikerNotificationWindow, NULL
> +        };
> +
> +        wndclass.hInstance = hProxyDll;
> +        notif_wnd_class = RegisterClassExW(&wndclass);
> +    }
> +
> +    LeaveCriticalSection(&notif_wnd_class_cs);
> +
> +    return notif_wnd_class != 0;
> +}

You don't really need a whole new critical section for this. Just use
InitOnce or interlocked functions.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list