comdlg32: Delay OleInitialize() until after file dialog window is created.

This fixes a problem exposed by commit
f65e04770d.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2017-02-02 16:10:06 +01:00 committed by Alexandre Julliard
parent 5dda6495eb
commit 1707df3da2
3 changed files with 7 additions and 7 deletions

View File

@ -252,7 +252,6 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
void *template;
HRSRC hRes;
HANDLE hDlgTmpl = 0;
HRESULT hr;
/* test for missing functionality */
if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
@ -297,9 +296,6 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
fodInfos->HookMsg.sharevistring = RegisterWindowMessageW(SHAREVISTRINGW);
}
/* Some shell namespace extensions depend on COM being initialized. */
hr = OleInitialize(NULL);
if (fodInfos->unicode)
lRes = DialogBoxIndirectParamW(COMDLG32_hInstance,
template,
@ -312,7 +308,7 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
fodInfos->ofnInfos->hwndOwner,
FileOpenDlgProc95,
(LPARAM) fodInfos);
if (SUCCEEDED(hr))
if (fodInfos->ole_initialized)
OleUninitialize();
/* Unable to create the dialog */
@ -1262,7 +1258,11 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
int gripx = GetSystemMetrics( SM_CYHSCROLL);
int gripy = GetSystemMetrics( SM_CYVSCROLL);
/* Adds the FileOpenDlgInfos in the property list of the dialog
/* Some shell namespace extensions depend on COM being initialized. */
if (SUCCEEDED(OleInitialize(NULL)))
fodInfos->ole_initialized = TRUE;
/* Adds the FileOpenDlgInfos in the property list of the dialog
so it will be easily accessible through a GetPropA(...) */
SetPropA(hwnd, FileOpenDlgInfosStr, fodInfos);

View File

@ -92,6 +92,7 @@ typedef struct
UINT sharevistring;
} HookMsg;
BOOL ole_initialized;
} FileOpenDlgInfos;
/***********************************************************************

View File

@ -1296,7 +1296,6 @@ static LRESULT CALLBACK hook_proc(int code, WPARAM wp, LPARAM lp)
* after GetOpenFileA() is a file dialog window. Mark Vista+
* behavior as broken. */
hr = OleInitialize(NULL);
todo_wine_if(first_dlg)
ok((first_dlg ? hr == S_OK : hr == S_FALSE)
|| broken(first_dlg && hr == S_FALSE),
"OleInitialize() returned %#x (first dialog %#x)\n", hr, first_dlg);