setupapi: Initialize COM if necessary when registering DLLs.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-02-10 14:41:31 -06:00 committed by Alexandre Julliard
parent e0b5da7b34
commit e75d5b8dc7
2 changed files with 15 additions and 1 deletions

View file

@ -1125,6 +1125,7 @@ BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section,
if (flags & SPINST_REGSVR)
{
struct register_dll_info info;
HRESULT hr;
info.unregister = FALSE;
info.modules_size = 0;
@ -1142,14 +1143,21 @@ BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section,
else
return FALSE;
hr = CoInitialize(NULL);
ret = iterate_section_fields( hinf, section, RegisterDlls, register_dlls_callback, &info );
for (i = 0; i < info.modules_count; i++) FreeLibrary( info.modules[i] );
if (SUCCEEDED(hr))
CoUninitialize();
HeapFree( GetProcessHeap(), 0, info.modules );
if (!ret) return FALSE;
}
if (flags & SPINST_UNREGSVR)
{
struct register_dll_info info;
HRESULT hr;
info.unregister = TRUE;
info.modules_size = 0;
@ -1162,8 +1170,14 @@ BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section,
}
else info.callback = NULL;
hr = CoInitialize(NULL);
ret = iterate_section_fields( hinf, section, UnregisterDlls, register_dlls_callback, &info );
for (i = 0; i < info.modules_count; i++) FreeLibrary( info.modules[i] );
if (SUCCEEDED(hr))
CoUninitialize();
HeapFree( GetProcessHeap(), 0, info.modules );
if (!ret) return FALSE;
}

View file

@ -2092,7 +2092,7 @@ static void test_register_dlls(void)
ok(ret, "Failed to install, error %#x.\n", GetLastError());
l = RegOpenKeyA(HKEY_CURRENT_USER, "winetest_setupapi_selfreg", &key);
todo_wine ok(!l, "Got error %u.\n", l);
ok(!l, "Got error %u.\n", l);
RegCloseKey(key);
ret = SetupInstallFromInfSectionA(NULL, hinf, "DefaultInstall", SPINST_UNREGSVR,