Windows writes a typelib's name into the registry when the typelib doesn't provide a documentation.
Signed-off-by: Bernhard Kölbl besentv@gmail.com --- dlls/oleaut32/tests/typelib.c | 34 ++++++++++++++++++++++++++++++++++ dlls/oleaut32/typelib.c | 34 ++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index bf38e71a259..d343928e054 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -6860,6 +6860,8 @@ static void test_RegisterTypeLib64(void) HRESULT hr; char filename[MAX_PATH]; WCHAR filenameW[MAX_PATH]; + REGSAM opposite = (sizeof(void*) == 8 ? KEY_WOW64_32KEY : KEY_WOW64_64KEY); + BOOL is_wow64 = FALSE;
static const WCHAR wszStdOle2[] = { 's','t','d','o','l','e','2','.','t','l','b',0 };
@@ -6880,6 +6882,9 @@ static void test_RegisterTypeLib64(void)
const SYSKIND sys = SYS_WIN64;
+ if (pIsWow64Process) + pIsWow64Process(GetCurrentProcess(), &is_wow64); + hr = LoadTypeLib(wszStdOle2, &stdole); ok(hr == S_OK, "got %08x\n", hr);
@@ -7013,10 +7018,39 @@ static void test_RegisterTypeLib64(void)
if(typeLib) { + WCHAR key_name[MAX_PATH], uuidW[40]; + OLECHAR tlbName[16]; + HKEY hkey; + LONG size; + hr = RegisterTypeLib(typeLib, filenameW, NULL); ok(hr == S_OK, "RegisterTypeLib returned: %08x\n", hr);
ITypeLib_Release(typeLib); + + StringFromGUID2(&tlcustguid, uuidW, ARRAY_SIZE(uuidW)); + swprintf(key_name, sizeof(key_name), L"TypeLib\%ls\1.0", uuidW); + + hr = RegOpenKeyExW(HKEY_CLASSES_ROOT, key_name, 0, KEY_READ, &hkey); + ok(hr == S_OK, "got %08x\n", hr); + + size = sizeof(tlbName); + hr = RegQueryValueW(hkey, L"", tlbName, &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); + + size = sizeof(tlbName); + hr = RegQueryValueW(hkey, L"", tlbName, &size); + ok(hr == S_OK, "got %08x\n", hr); + } + + ok(!wcscmp(tlbName, typelibW), + "Got unexpected TypLib description: %ls\n", tlbName); }
DeleteFileW(filenameW); 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;