From b0efdcbdbd9de273abf5bda9302c5bdfea044613 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Wed, 28 Jun 2006 21:24:38 +0100 Subject: [PATCH] ole32: Implement CoGetObject. --- dlls/ole32/compobj.c | 52 +++++++++++++++++++++++++++++++++++++++++++ dlls/ole32/ole32.spec | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 1a8ab45b0fd..fc65ddb1f37 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -2909,6 +2909,58 @@ HRESULT WINAPI CoWaitForMultipleHandles(DWORD dwFlags, DWORD dwTimeout, return hr; } + +/*********************************************************************** + * CoGetObject [OLE32.@] + * + * Gets the object named by coverting the name to a moniker and binding to it. + * + * PARAMS + * pszName [I] String representing the object. + * pBindOptions [I] Parameters affecting the binding to the named object. + * riid [I] Interface to bind to on the objecct. + * ppv [O] On output, the interface riid of the object represented + * by pszName. + * + * RETURNS + * Success: S_OK. + * Failure: HRESULT code. + * + * SEE ALSO + * MkParseDisplayName. + */ +HRESULT WINAPI CoGetObject(LPCWSTR pszName, BIND_OPTS *pBindOptions, + REFIID riid, void **ppv) +{ + IBindCtx *pbc; + HRESULT hr; + + *ppv = NULL; + + hr = CreateBindCtx(0, &pbc); + if (SUCCEEDED(hr)) + { + if (pBindOptions) + hr = IBindCtx_SetBindOptions(pbc, pBindOptions); + + if (SUCCEEDED(hr)) + { + ULONG chEaten; + IMoniker *pmk; + + hr = MkParseDisplayName(pbc, pszName, &chEaten, &pmk); + if (SUCCEEDED(hr)) + { + hr = IMoniker_BindToObject(pmk, pbc, NULL, riid, ppv); + IMoniker_Release(pmk); + } + } + + IBindCtx_Release(pbc); + } + return hr; +} + /*********************************************************************** * DllMain (OLE32.@) */ diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index 74f2bfc1c74..56058bbe5cd 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -30,7 +30,7 @@ @ stdcall CoGetInterfaceAndReleaseStream(ptr ptr ptr) @ stdcall CoGetMalloc(long ptr) @ stdcall CoGetMarshalSizeMax(ptr ptr ptr long ptr long) -@ stub CoGetObject +@ stdcall CoGetObject(wstr ptr ptr ptr) @ stdcall CoGetPSClsid(ptr ptr) @ stdcall CoGetStandardMarshal(ptr ptr long ptr long ptr) @ stdcall CoGetState(ptr)