From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/oleaut32/tests/typelib.c | 37 +++++++++++++++++++++++++++++++++++ dlls/oleaut32/typelib.c | 23 ++++++++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 59b2ea7c93e..9c2b3218e80 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -8366,6 +8366,42 @@ static void test_dep(void) { DeleteFileW(filenameW); }
+static void test_DeleteTypeInfo(void) +{ + static OLECHAR interface1W[] = L"interface1"; + static OLECHAR interface2W[] = L"interface2"; + ICreateTypeInfo *createti; + ICreateTypeLib2 *createtl; + WCHAR filenameW[MAX_PATH]; + ITypeLib *stdole; + HRESULT hr; + + hr = LoadTypeLib(L"stdole2.tlb", &stdole); + ok(hr == S_OK, "Failed to load stdole2, hr %#lx.\n", hr); + + GetTempFileNameW(L".", L"tlb", 0, filenameW); + + hr = CreateTypeLib2(SYS_WIN32, filenameW, &createtl); + ok(hr == S_OK, "Failed to create instance, hr %#lx.\n", hr); + + hr = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti); + ok(hr == S_OK, "Failed to create instance, hr %#lx.\n", hr); + ICreateTypeInfo_Release(createti); + + hr = ICreateTypeLib2_DeleteTypeInfo(createtl, NULL); + ok(hr == E_INVALIDARG, "got %08lx\n", hr); + + hr = ICreateTypeLib2_DeleteTypeInfo(createtl, interface2W); + ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08lx\n", hr); + + hr = ICreateTypeLib2_DeleteTypeInfo(createtl, interface1W); + ok(hr == S_OK, "got %08lx\n", hr); + + ITypeLib_Release(stdole); + + DeleteFileW(filenameW); +} + static void test_DeleteImplType(void) { static OLECHAR interface1W[] = L"interface1"; @@ -8581,6 +8617,7 @@ START_TEST(typelib) test_GetLibAttr(); test_stub(); test_dep(); + test_DeleteTypeInfo(); test_DeleteImplType(); test_DeleteFuncDesc(); } diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index dc354184d36..fa59dc62b2f 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -10389,8 +10389,27 @@ static HRESULT WINAPI ICreateTypeLib2_fnDeleteTypeInfo(ICreateTypeLib2 *iface, LPOLESTR name) { ITypeLibImpl *This = impl_from_ICreateTypeLib2(iface); - FIXME("%p %s - stub\n", This, wine_dbgstr_w(name)); - return E_NOTIMPL; + int i; + TRACE("%p %s\n", This, wine_dbgstr_w(name)); + + if (!name) + return E_INVALIDARG; + + for (i = 0; i < This->TypeInfoCount; ++i) + { + if (!lstrcmpiW(TLB_get_bstr(This->typeinfos[i]->Name), name)) + { + ITypeInfoImpl_Destroy(This->typeinfos[i]); + + This->TypeInfoCount--; + if (i < This->TypeInfoCount) + memmove(This->typeinfos + i, This->typeinfos + i + 1, (This->TypeInfoCount - i) * + sizeof(*This->typeinfos)); + return S_OK; + } + } + + return TYPE_E_ELEMENTNOTFOUND; }
static HRESULT WINAPI ICreateTypeLib2_fnSetCustData(ICreateTypeLib2 *iface,