>From cdde8c25be14bd23f244ed511f2496f82bd0c232 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Sun, 8 Jan 2012 03:46:41 +0300
Subject: [PATCH 09/13] Fix SHLoadInProc() return value

---
 dlls/shell32/shell32_main.c   |   16 +++++++---------
 dlls/shell32/tests/shellole.c |   24 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c
index 5370b99..fe25aae 100644
--- a/dlls/shell32/shell32_main.c
+++ b/dlls/shell32/shell32_main.c
@@ -923,18 +923,16 @@ DWORD WINAPI SHHelpShortcuts_RunDLLW(DWORD dwArg1, DWORD dwArg2, DWORD dwArg3, D
  */
 HRESULT WINAPI SHLoadInProc (REFCLSID rclsid)
 {
-    void *ptr = NULL;
+    IUnknown *unk = NULL;
+    HRESULT hr;
 
     TRACE("%s\n", debugstr_guid(rclsid));
 
-    CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown,&ptr);
-    if(ptr)
-    {
-        IUnknown * pUnk = ptr;
-        IUnknown_Release(pUnk);
-        return S_OK;
-    }
-    return DISP_E_MEMBERNOTFOUND;
+    hr = CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&unk);
+    if (unk)
+        IUnknown_Release(unk);
+
+    return hr;
 }
 
 static void add_authors( HWND list )
diff --git a/dlls/shell32/tests/shellole.c b/dlls/shell32/tests/shellole.c
index da1f667..9e13970 100644
--- a/dlls/shell32/tests/shellole.c
+++ b/dlls/shell32/tests/shellole.c
@@ -69,6 +69,7 @@ static HRESULT (WINAPI *pSHPropStgReadMultiple)(IPropertyStorage*, UINT,
         ULONG, const PROPSPEC*, PROPVARIANT*);
 static HRESULT (WINAPI *pSHPropStgWriteMultiple)(IPropertyStorage*, UINT*,
         ULONG, const PROPSPEC*, PROPVARIANT*, PROPID);
+static HRESULT (WINAPI *pSHLoadInProc)(REFCLSID);
 
 static void init(void)
 {
@@ -77,6 +78,7 @@ static void init(void)
     pSHPropStgCreate = (void*)GetProcAddress(hmod, "SHPropStgCreate");
     pSHPropStgReadMultiple = (void*)GetProcAddress(hmod, "SHPropStgReadMultiple");
     pSHPropStgWriteMultiple = (void*)GetProcAddress(hmod, "SHPropStgWriteMultiple");
+    pSHLoadInProc = (void*)GetProcAddress(hmod, "SHLoadInProc");
 }
 
 static HRESULT WINAPI PropertyStorage_QueryInterface(IPropertyStorage *This,
@@ -429,9 +431,31 @@ static void test_SHPropStg_functions(void)
     CHECK_CALLED(Stat);
 }
 
+static void test_SHLoadInProc(void)
+{
+    HRESULT hr;
+
+    if (!pSHLoadInProc)
+    {
+        win_skip("SHLoadInProc is not available\n");
+        return;
+    }
+
+if (0)
+{
+    /* crashes */
+    hr = pSHLoadInProc(NULL);
+}
+
+    hr = pSHLoadInProc(&IID_NULL);
+todo_wine
+    ok(hr == REGDB_E_CLASSNOTREG, "got 0x%08x\n", hr);
+}
+
 START_TEST(shellole)
 {
     init();
 
     test_SHPropStg_functions();
+    test_SHLoadInProc();
 }
-- 
1.5.6.5


