Jacek Caban jacek@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, ¬if_wnd_class_cs,
- { ¬if_wnd_class_cs_dbg.ProcessLocksList, ¬if_wnd_class_cs_dbg.ProcessLocksList },
- 0, 0, { (DWORD_PTR)(__FILE__ ": notif_wnd_class") }
+}; +static CRITICAL_SECTION notif_wnd_class_cs = { ¬if_wnd_class_cs_dbg, -1, 0, 0, 0, 0 };
+static BOOL ensure_notif_wnd_class(void) +{
- EnterCriticalSection(¬if_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(¬if_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.