Bug Fix With Delay load function in Shell32 (version2)

Robert Shearman R.J.Shearman at warwick.ac.uk
Sun Jan 12 11:08:24 CST 2003


Here is the updated patch:

> -----Original Message-----
> From: Jürgen Schmied [mailto:j.schmied at t-online.de]
> Sent: 12 January 2003 13:45
> To: Robert Shearman; wine-devel at winehq.com
> Subject: Re: Bug Fix With Delay load function in Shell32

> > ChangeLog:
> > - Set up all delay load functions in GetShellOle() function to avoid
> > GetShellOle assuming that they were all loaded when they weren't

> This isn't the best solution since GetShellOle() initializes the
> ole subsystem by calling
> OleInitialize(). This is not nessesary for _CoCreateInstance().

ChangeLog:
- Seperate the HINSTANCEs used by GetShellOle() and other delay load
functions
-------------- next part --------------
Index: clipboard.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/clipboard.c,v
retrieving revision 1.13
diff -u -r1.13 clipboard.c
--- clipboard.c	13 Dec 2002 00:36:52 -0000	1.13
+++ clipboard.c	12 Jan 2003 16:38:40 -0000
@@ -63,24 +63,25 @@
  */
 BOOL GetShellOle(void)
 {
-	if(!hShellOle32)
-	{
-	  hShellOle32 = LoadLibraryA("ole32.dll");
-	  if(hShellOle32)
-	  {
-	    pOleInitialize=(void*)GetProcAddress(hShellOle32,"OleInitialize");
-	    pOleUninitialize=(void*)GetProcAddress(hShellOle32,"OleUninitialize");
-	    pRegisterDragDrop=(void*)GetProcAddress(hShellOle32,"RegisterDragDrop");
-	    pRevokeDragDrop=(void*)GetProcAddress(hShellOle32,"RevokeDragDrop");
-	    pDoDragDrop=(void*)GetProcAddress(hShellOle32,"DoDragDrop");
-	    pReleaseStgMedium=(void*)GetProcAddress(hShellOle32,"ReleaseStgMedium");
-	    pOleSetClipboard=(void*)GetProcAddress(hShellOle32,"OleSetClipboard");
-	    pOleGetClipboard=(void*)GetProcAddress(hShellOle32,"OleGetClipboard");
+    static HANDLE hOle32 = NULL;
+    if(!hOle32)
+    {
+        hOle32 = LoadLibraryA("ole32.dll");
+        if(hOle32)
+        {
+            pOleInitialize=(void*)GetProcAddress(hOle32,"OleInitialize");
+            pOleUninitialize=(void*)GetProcAddress(hOle32,"OleUninitialize");
+            pRegisterDragDrop=(void*)GetProcAddress(hOle32,"RegisterDragDrop");
+            pRevokeDragDrop=(void*)GetProcAddress(hOle32,"RevokeDragDrop");
+            pDoDragDrop=(void*)GetProcAddress(hOle32,"DoDragDrop");
+            pReleaseStgMedium=(void*)GetProcAddress(hOle32,"ReleaseStgMedium");
+            pOleSetClipboard=(void*)GetProcAddress(hOle32,"OleSetClipboard");
+            pOleGetClipboard=(void*)GetProcAddress(hOle32,"OleGetClipboard");
 
-	    pOleInitialize(NULL);
-	  }
-	}
-	return TRUE;
+            pOleInitialize(NULL);
+        }
+    }
+    return TRUE;
 }
 
 /**************************************************************************
Index: shellole.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shellole.c,v
retrieving revision 1.55
diff -u -r1.55 shellole.c
--- shellole.c	3 Jan 2003 03:07:21 -0000	1.55
+++ shellole.c	12 Jan 2003 16:38:44 -0000
@@ -47,7 +47,7 @@
 const WCHAR sShell32[12] = {'S','H','E','L','L','3','2','.','D','L','L','\0'};
 const WCHAR sOLE32[10] = {'O','L','E','3','2','.','D','L','L','\0'};
 
-HINSTANCE hShellOle32 = 0;
+HINSTANCE g_hShellOle32 = 0; /* global handle to ole32.dll */
 /**************************************************************************
  * Default ClassFactory types
  */
@@ -86,7 +86,7 @@
 
 HRESULT  __CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
 {
-	if(!pCoCreateInstance) pCoCreateInstance = __GetExternalFunc(&hShellOle32, sOLE32, "CoCreateInstance");
+	if(!pCoCreateInstance) pCoCreateInstance = __GetExternalFunc(&g_hShellOle32, sOLE32, "CoCreateInstance");
 	if(!pCoCreateInstance) return E_FAIL;
 	return pCoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, ppv);
 }


More information about the wine-patches mailing list