[PATCH v2 2/2] oleaut32: Register a typelib's name if a documentation is not available.
Bernhard Kölbl
besentv at gmail.com
Wed Oct 20 09:21:39 CDT 2021
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>
---
v2: Style improvements.
---
dlls/oleaut32/tests/typelib.c | 39 +++++++++++++++++++++++++++++++++++
dlls/oleaut32/typelib.c | 34 +++++++++++++++++++++++-------
2 files changed, 65 insertions(+), 8 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..9c18a383285 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -636,18 +636,36 @@ HRESULT WINAPI RegisterTypeLib(ITypeLib *ptlib, const WCHAR *szFullPath, const W
KEY_WRITE, NULL, &key, NULL) == ERROR_SUCCESS)
{
LPOLESTR doc;
+ LPOLESTR libName;
+ BOOL nameSet = FALSE;
- /* Set the human-readable name of the typelib */
- if (FAILED(ITypeLib_GetDocumentation(ptlib, -1, NULL, &doc, NULL, NULL)))
- res = E_FAIL;
- else if (doc)
+ /* Set the human-readable name of the typelib to
+ the typelib's doc, if it exists, else to the typelib's name. */
+ if (SUCCEEDED(ITypeLib_GetDocumentation(ptlib, -1, &libName, &doc, NULL, NULL)))
{
- if (RegSetValueExW(key, NULL, 0, REG_SZ,
- (BYTE *)doc, (lstrlenW(doc)+1) * sizeof(OLECHAR)) != ERROR_SUCCESS)
- res = E_FAIL;
+ if (doc)
+ {
+ if (RegSetValueExW(key, NULL, 0, REG_SZ,
+ (BYTE *)doc, (lstrlenW(doc)+1) * sizeof(OLECHAR)) != ERROR_SUCCESS)
+ res = E_FAIL;
+
+ nameSet = TRUE;
+ SysFreeString(doc);
+ }
+ if(libName)
+ {
+ if(!nameSet)
+ {
+ if (RegSetValueExW(key, NULL, 0, REG_SZ,
+ (BYTE *)libName, (lstrlenW(libName)+1) * sizeof(OLECHAR)) != ERROR_SUCCESS)
+ res = E_FAIL;
+ }
- SysFreeString(doc);
+ SysFreeString(libName);
+ }
}
+ else
+ res = E_FAIL;
/* Make up the name of the typelib path subkey */
if (!get_lcid_subkey( attr->lcid, attr->syskind, tmp )) res = E_FAIL;
--
2.33.0
More information about the wine-devel
mailing list