Bernhard Kölbl : oleaut32: Register a typelib's name if a documentation is not available.
Alexandre Julliard
julliard at winehq.org
Thu Oct 21 16:04:17 CDT 2021
Module: wine
Branch: master
Commit: fdc2d415b0dd5c12c83156bd41161ff135d25105
URL: https://source.winehq.org/git/wine.git/?a=commit;h=fdc2d415b0dd5c12c83156bd41161ff135d25105
Author: Bernhard Kölbl <besentv at gmail.com>
Date: Wed Oct 20 16:21:39 2021 +0200
oleaut32: Register a typelib's name if a documentation is not available.
Windows writes a typelib's name into the registry when the typelib
doesn't provide a documentation.
Signed-off-by: Bernhard Kölbl <besentv at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/oleaut32/tests/typelib.c | 39 +++++++++++++++++++++++++++++++++++++++
dlls/oleaut32/typelib.c | 13 +++++++++----
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c
index 78290c94dfe..fd83c3abb8a 100644
--- a/dlls/oleaut32/tests/typelib.c
+++ b/dlls/oleaut32/tests/typelib.c
@@ -6850,6 +6850,7 @@ static void test_register_typelib(BOOL system_registration)
static void test_register_typelib_64(void)
{
+ REGSAM opposite = (sizeof(void*) == 8 ? KEY_WOW64_32KEY : KEY_WOW64_64KEY);
ICreateTypeInfo *createti, *createti_co;
ELEMDESC elemdesc[5], elemdesc2[5];
FUNCDESC funcdesc, funcdesc2;
@@ -6857,6 +6858,7 @@ static void test_register_typelib_64(void)
ITypeLib *stdole, *typelib;
ICreateTypeLib2 *createtl;
WCHAR filename[MAX_PATH];
+ BOOL is_wow64 = FALSE;
HREFTYPE hreftype;
HRESULT hr;
@@ -6879,6 +6881,9 @@ static void test_register_typelib_64(void)
static const SYSKIND sys = SYS_WIN64;
+ if (pIsWow64Process)
+ pIsWow64Process(GetCurrentProcess(), &is_wow64);
+
hr = LoadTypeLib(wszStdOle2, &stdole);
ok(hr == S_OK, "got %08x\n", hr);
@@ -7011,6 +7016,11 @@ static void test_register_typelib_64(void)
if(typelib)
{
+ WCHAR key_name[MAX_PATH], uuid[40];
+ OLECHAR tlb_name[16];
+ HKEY hkey;
+ LONG size;
+
hr = RegisterTypeLib(typelib, filename, NULL);
if (hr == TYPE_E_REGISTRYACCESS)
{
@@ -7022,6 +7032,35 @@ static void test_register_typelib_64(void)
ok(hr == S_OK, "got: %08x\n", hr);
ITypeLib_Release(typelib);
+
+ StringFromGUID2(&tlcustguid, uuid, ARRAY_SIZE(uuid));
+ swprintf(key_name, sizeof(key_name), L"TypeLib\\%ls\\1.0", uuid);
+
+ hr = RegOpenKeyExW(HKEY_CLASSES_ROOT, key_name, 0, KEY_READ, &hkey);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ size = sizeof(tlb_name);
+ hr = RegQueryValueW(hkey, L"", tlb_name, &size);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ /* The typelib should be registered in WoW64_32 and WoW64_64 mode */
+ if(is_win64 || is_wow64)
+ {
+ hr = RegOpenKeyExW(HKEY_CLASSES_ROOT, key_name, 0, KEY_READ | opposite, &hkey);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ if(hkey)
+ {
+ size = sizeof(tlb_name);
+ hr = RegQueryValueW(hkey, L"", tlb_name, &size);
+ ok(hr == S_OK, "got %08x\n", hr);
+
+ RegCloseKey(hkey);
+ }
+ }
+
+ ok(!wcscmp(tlb_name, typelibW),
+ "Got unexpected TypLib description: %ls\n", tlb_name);
}
DeleteFileW(filename);
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index ef546379174..e050726a4ee 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -636,17 +636,22 @@ HRESULT WINAPI RegisterTypeLib(ITypeLib *ptlib, const WCHAR *szFullPath, const W
KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS)
{
LPOLESTR doc;
+ LPOLESTR libName;
- /* Set the human-readable name of the typelib */
- if (FAILED(ITypeLib_GetDocumentation(ptlib, -1, NULL, &doc, NULL, NULL)))
+ /* Set the human-readable name of the typelib to
+ the typelib's doc, if it exists, else to the typelib's name. */
+ if (FAILED(ITypeLib_GetDocumentation(ptlib, -1, &libName, &doc, NULL, NULL)))
res = E_FAIL;
- else if (doc)
+ else if (doc || libName)
{
+ WCHAR *name = doc ? doc : libName;
+
if (RegSetValueExW(key, NULL, 0, REG_SZ,
- (BYTE *)doc, (lstrlenW(doc)+1) * sizeof(OLECHAR)) != ERROR_SUCCESS)
+ (BYTE *)name, (lstrlenW(name)+1) * sizeof(OLECHAR)) != ERROR_SUCCESS)
res = E_FAIL;
SysFreeString(doc);
+ SysFreeString(libName);
}
/* Make up the name of the typelib path subkey */
More information about the wine-cvs
mailing list