Index: /trunk/src/ole32/ole2.cpp
===================================================================
--- /trunk/src/ole32/ole2.cpp	(revision 5279)
+++ /trunk/src/ole32/ole2.cpp	(revision 5280)
@@ -1,13 +1,13 @@
-/* $Id: ole2.cpp,v 1.4 2001-02-27 22:25:54 hugh Exp $ */
-/*
- *
+/* $Id: ole2.cpp,v 1.5 2001-02-28 20:30:22 sandervl Exp $ */
+/* 
+ * 
  * Project Odin Software License can be found in LICENSE.TXT
- *
+ * 
  */
-/*
+/* 
  * OLE functions.
- *
+ * 
  * 2/9/99
- *
+ * 
  * Copyright 1999 David J. Raison
  *
@@ -15,5 +15,5 @@
  *   Copyright 1995  Martin von Loewis
  *   Copyright 1999  Francis Beaudet
- *   Copyright 1999  Noel Borthwick
+ *   Copyright 1999  Noel Borthwick 
  */
 
@@ -24,7 +24,7 @@
 #include <assert.h>
 
-// ======================================================================
+// ====================================================================== 
 // Local Data
-// ======================================================================
+// ====================================================================== 
 
 /*
@@ -35,24 +35,24 @@
 
 
-// ======================================================================
+// ====================================================================== 
 // Prototypes.
-// ======================================================================
+// ====================================================================== 
 static void OLEUTL_ReadRegistryDWORDValue(HKEY regKey, DWORD* pdwValue);
 
 // These are the prototypes of the utility methods used to manage a shared menu
-extern  void  OLEMenu_Initialize();
-extern  void  OLEMenu_UnInitialize();
+extern	void	OLEMenu_Initialize();
+extern	void	OLEMenu_UnInitialize();
 
 // These are the prototypes of the OLE Clipboard initialization methods (in clipboard.c)
-extern  void  OLEClipbrd_UnInitialize();
-extern  void  OLEClipbrd_Initialize();
+extern	void	OLEClipbrd_UnInitialize();
+extern	void	OLEClipbrd_Initialize();
 
 // These are the prototypes of the utility methods used for OLE Drag n Drop
-extern  void  OLEDD_Initialize();
-extern  void  OLEDD_UnInitialize();
-
-// ======================================================================
+extern	void	OLEDD_Initialize();
+extern	void	OLEDD_UnInitialize();
+
+// ====================================================================== 
 // Public API's
-// ======================================================================
+// ====================================================================== 
 
 // ----------------------------------------------------------------------
@@ -77,5 +77,5 @@
     hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
     if (FAILED(hr))
-  return hr;
+	return hr;    
 
     // Then, it has to initialize the OLE specific modules.
@@ -87,14 +87,14 @@
     if (++OLE_moduleLockCount == 1)
     {
-  dprintf(("    First time through - Initializing"));
-
-  // OLE Clipboard
-  OLEClipbrd_Initialize();
-
-  // Drag and Drop
-  OLEDD_Initialize();
-
-  // OLE shared menu
-  OLEMenu_Initialize();
+	dprintf(("    First time through - Initializing"));
+
+	// OLE Clipboard
+	OLEClipbrd_Initialize();
+
+	// Drag and Drop
+	OLEDD_Initialize();
+
+	// OLE shared menu
+	OLEMenu_Initialize();
     }
 
@@ -121,14 +121,14 @@
     if (--OLE_moduleLockCount == 0)
     {
-  dprintf(("    no more references - Terminating"));
-
-  // OLE Clipboard
-  OLEClipbrd_UnInitialize();
-
-  // Drag and Drop
-  OLEDD_UnInitialize();
-
-  // OLE shared menu
-  OLEMenu_UnInitialize();
+	dprintf(("    no more references - Terminating"));
+
+	// OLE Clipboard
+	OLEClipbrd_UnInitialize();
+
+	// Drag and Drop
+	OLEDD_UnInitialize();
+
+	// OLE shared menu
+	OLEMenu_UnInitialize();
     }
 
@@ -146,15 +146,15 @@
 // ----------------------------------------------------------------------
 HRESULT WIN32API OleRegGetUserType
-   (REFCLSID    clsid,
-    DWORD   dwFormOfType,
-    LPOLESTR *    pszUserType)
-
-{
-    oStringA    tCLSID;
-    DWORD   dwKeyType;
-    DWORD   cbData;
-    HKEY    clsidKey;
-    LONG    hres;
-    LPSTR     buffer;
+   (REFCLSID		clsid, 
+    DWORD		dwFormOfType,
+    LPOLESTR *		pszUserType)
+
+{
+    oStringA		tCLSID;
+    DWORD		dwKeyType;
+    DWORD		cbData;
+    HKEY 		clsidKey;
+    LONG 		hres;
+    LPSTR  		buffer;
 
     dprintf(("OLE32: OleRegGetUserType"));
@@ -165,10 +165,10 @@
     tCLSID = "CLSID\\";
     tCLSID += clsid;
-    tCLSID += "}";
+    tCLSID += "\\";
 
     // Open the class id Key
     hres = RegOpenKeyA(HKEY_CLASSES_ROOT, tCLSID, &clsidKey);
     if (hres != ERROR_SUCCESS)
-  return REGDB_E_CLASSNOTREG;
+	return REGDB_E_CLASSNOTREG;
 
     // Retrieve the size of the name string.
@@ -177,6 +177,6 @@
     if (hres != ERROR_SUCCESS)
     {
-  RegCloseKey(clsidKey);
-  return REGDB_E_READREGDB;
+	RegCloseKey(clsidKey);
+	return REGDB_E_READREGDB;
     }
 
@@ -186,6 +186,6 @@
     if (buffer == NULL)
     {
-  RegCloseKey(clsidKey);
-  return E_OUTOFMEMORY;
+	RegCloseKey(clsidKey);
+	return E_OUTOFMEMORY;
     }
 
@@ -194,6 +194,6 @@
     if (hres != ERROR_SUCCESS)
     {
-  HeapFree(GetProcessHeap(), 0, buffer);
-  return REGDB_E_READREGDB;
+	HeapFree(GetProcessHeap(), 0, buffer);
+	return REGDB_E_READREGDB;
     }
 
@@ -203,6 +203,6 @@
     if (*pszUserType == NULL)
     {
-  HeapFree(GetProcessHeap(), 0, buffer);
-  return E_OUTOFMEMORY;
+	HeapFree(GetProcessHeap(), 0, buffer);
+	return E_OUTOFMEMORY;
     }
 
@@ -218,13 +218,13 @@
 // ----------------------------------------------------------------------
 HRESULT WIN32API OleRegGetMiscStatus
-   (REFCLSID    clsid,
-    DWORD   dwAspect,
-    DWORD *   pdwStatus)
-{
-    oStringA    tStr;
-    HKEY        clsidKey;
-    HKEY        miscStatusKey;
-    HKEY        aspectKey;
-    LONG        result;
+   (REFCLSID		clsid,
+    DWORD		dwAspect,
+    DWORD *		pdwStatus)
+{
+    oStringA		tStr;
+    HKEY    		clsidKey;
+    HKEY    		miscStatusKey;
+    HKEY    		aspectKey;
+    LONG    		result;
 
     dprintf(("OLE32: OleRegGetMiscStatus"));
@@ -236,5 +236,5 @@
     tStr = "CLSID\\";
     tStr += clsid;
-    tStr += "}";
+    tStr += "\\";
     dprintf(("       Key   : %s", (char *)tStr));
 
@@ -243,5 +243,5 @@
 
     if (result != ERROR_SUCCESS)
-  return REGDB_E_CLASSNOTREG;
+	return REGDB_E_CLASSNOTREG;
 
     // Get the MiscStatus
@@ -250,6 +250,6 @@
     if (result != ERROR_SUCCESS)
     {
-  RegCloseKey(clsidKey);
-  return REGDB_E_READREGDB;
+	RegCloseKey(clsidKey);
+	return REGDB_E_READREGDB;
     }
 
@@ -258,5 +258,5 @@
 
     // Open the key specific to the requested aspect.
-    oStringA    tKey(dwAspect);
+    oStringA		tKey(dwAspect);
     dprintf(("       Aspect: %s", (char *)tKey));
 
@@ -265,6 +265,6 @@
     if (result == ERROR_SUCCESS)
     {
-  OLEUTL_ReadRegistryDWORDValue(aspectKey, pdwStatus);
-  RegCloseKey(aspectKey);
+	OLEUTL_ReadRegistryDWORDValue(aspectKey, pdwStatus);
+	RegCloseKey(aspectKey);
     }
 
@@ -280,9 +280,9 @@
 // ----------------------------------------------------------------------
 HRESULT WIN32API OleSetContainedObject
-   (LPUNKNOWN   pUnknown,
-    BOOL          fContained)
-{
-    IRunnableObject * runnable = NULL;
-    HRESULT           hres;
+   (LPUNKNOWN		pUnknown, 
+    BOOL      		fContained)
+{
+    IRunnableObject *	runnable = NULL;
+    HRESULT          	hres;
 
     dprintf(("OLE32: OleSetContainedObject"));
@@ -292,9 +292,9 @@
     if (SUCCEEDED(hres))
     {
-  hres = IRunnableObject_SetContainedObject(runnable, fContained);
-
-  IRunnableObject_Release(runnable);
-
-  return hres;
+	hres = IRunnableObject_SetContainedObject(runnable, fContained);
+
+	IRunnableObject_Release(runnable);
+
+	return hres;
     }
 
@@ -306,13 +306,13 @@
 // ----------------------------------------------------------------------
 HRESULT WIN32API OleLoad
-   (LPSTORAGE   pStg,
-    REFIID            riid,
-    LPOLECLIENTSITE   pClientSite,
-    LPVOID *          ppvObj)
-{
-    IPersistStorage * persistStorage = NULL;
-    IOleObject *        oleObject      = NULL;
-    STATSTG           storageInfo;
-    HRESULT           hres;
+   (LPSTORAGE		pStg, 
+    REFIID          	riid, 
+    LPOLECLIENTSITE 	pClientSite, 
+    LPVOID *         	ppvObj)
+{
+    IPersistStorage *	persistStorage = NULL;
+    IOleObject *      	oleObject      = NULL;
+    STATSTG          	storageInfo;
+    HRESULT          	hres;
 
     dprintf(("OLE32: OleLoad"));
@@ -325,21 +325,21 @@
     // Now, try and create the handler for the object
     hres = CoCreateInstance(&storageInfo.clsid,
-              NULL,
-              CLSCTX_INPROC_HANDLER,
-              &IID_IOleObject,
-              (void**)&oleObject);
+    			    NULL,
+    			    CLSCTX_INPROC_HANDLER,
+    			    &IID_IOleObject,
+    			    (void**)&oleObject);
 
     // If that fails, as it will most times, load the default OLE handler.
     if (FAILED(hres))
     {
-  hres = OleCreateDefaultHandler(&storageInfo.clsid,
-               NULL,
-               &IID_IOleObject,
-               (void**)&oleObject);
+	hres = OleCreateDefaultHandler(&storageInfo.clsid,
+				       NULL,
+				       &IID_IOleObject,
+				       (void**)&oleObject);
     }
 
     // If we couldn't find a handler... this is bad. Abort the whole thing.
     if (FAILED(hres))
-  return hres;
+	return hres;
 
     // Inform the new object of it's client site.
@@ -349,10 +349,10 @@
     hres = IOleObject_QueryInterface(oleObject, &IID_IPersistStorage, (void**)&persistStorage);
 
-    if (SUCCEEDED(hres))
-    {
-  IPersistStorage_Load(persistStorage, pStg);
-
-  IPersistStorage_Release(persistStorage);
-  persistStorage = NULL;
+    if (SUCCEEDED(hres)) 
+    {
+	IPersistStorage_Load(persistStorage, pStg);
+
+	IPersistStorage_Release(persistStorage);
+	persistStorage = NULL;
     }
 
@@ -370,10 +370,10 @@
 // ----------------------------------------------------------------------
 HRESULT WIN32API OleSave
-   (LPPERSISTSTORAGE    pPS,
-    LPSTORAGE           pStg,
-    BOOL                fSameAsLoad)
-{
-    HRESULT     hres;
-    CLSID     objectClass;
+   (LPPERSISTSTORAGE		pPS,
+    LPSTORAGE        		pStg,
+    BOOL             		fSameAsLoad)
+{
+    HRESULT			hres;
+    CLSID			objectClass;
 
     dprintf(("OLE32: OleSave"));
@@ -383,5 +383,5 @@
 
     if (SUCCEEDED(hres))
-  WriteClassStg(pStg, &objectClass);
+	WriteClassStg(pStg, &objectClass);
 
     // Then, we ask the object to save itself to the
@@ -390,5 +390,5 @@
 
     if (SUCCEEDED(hres))
-  IStorage_Commit(pStg, STGC_DEFAULT);
+	IStorage_Commit(pStg, STGC_DEFAULT);
 
     return hres;
@@ -402,74 +402,74 @@
     switch (pmedium->tymed)
     {
-  case TYMED_HGLOBAL:
-  {
-      if ( (pmedium->pUnkForRelease == 0) && (pmedium->u.hGlobal  != 0) )
-    GlobalFree(pmedium->u.hGlobal);
-
-      pmedium->u.hGlobal = 0;
-      break;
-  }
-  case TYMED_FILE:
-  {
-      if (pmedium->u.lpszFileName != 0)
-      {
-    if (pmedium->pUnkForRelease == 0)
-        DeleteFileW(pmedium->u.lpszFileName);
-
-    CoTaskMemFree(pmedium->u.lpszFileName);
-      }
-
-      pmedium->u.lpszFileName = 0;
-      break;
-  }
-  case TYMED_ISTREAM:
-  {
-      if (pmedium->u.pstm != 0)
-    IStream_Release(pmedium->u.pstm);
-
-      pmedium->u.pstm = 0;
-      break;
-  }
-  case TYMED_ISTORAGE:
-  {
-      if (pmedium->u.pstg != 0)
-    IStorage_Release(pmedium->u.pstg);
-
-      pmedium->u.pstg = 0;
-      break;
-  }
-  case TYMED_GDI:
-  {
-      if ( (pmedium->pUnkForRelease == 0) && (pmedium->u.hGlobal != 0) )
-    DeleteObject(pmedium->u.hGlobal);
-
-      pmedium->u.hGlobal = 0;
-      break;
-  }
-  case TYMED_MFPICT:
-  {
-      if ( (pmedium->pUnkForRelease == 0) && (pmedium->u.hMetaFilePict != 0) )
-      {
-    DeleteMetaFile(pmedium->u.hMetaFilePict);
-    GlobalFree(pmedium->u.hMetaFilePict);
-      }
-
-      pmedium->u.hMetaFilePict = 0;
-      break;
-  }
-  case TYMED_ENHMF:
-  {
-      if ( (pmedium->pUnkForRelease == 0) && (pmedium->u.hEnhMetaFile != 0) )
-    DeleteEnhMetaFile(pmedium->u.hEnhMetaFile);
-
-      pmedium->u.hEnhMetaFile = 0;
-      break;
-  }
-  case TYMED_NULL:
-      // Do nothing
-      break;
-
-  default:
-      break;
+	case TYMED_HGLOBAL:
+	{
+	    if ( (pmedium->pUnkForRelease == 0) && (pmedium->u.hGlobal  != 0) )
+		GlobalFree(pmedium->u.hGlobal);
+
+	    pmedium->u.hGlobal = 0;
+	    break;
+	}
+	case TYMED_FILE:
+	{
+	    if (pmedium->u.lpszFileName != 0)
+	    {
+		if (pmedium->pUnkForRelease == 0)
+		    DeleteFileW(pmedium->u.lpszFileName);
+
+		CoTaskMemFree(pmedium->u.lpszFileName);
+	    }
+
+	    pmedium->u.lpszFileName = 0;
+	    break;
+	}
+	case TYMED_ISTREAM:
+	{
+	    if (pmedium->u.pstm != 0)
+		IStream_Release(pmedium->u.pstm);
+
+	    pmedium->u.pstm = 0;
+	    break;
+	}
+	case TYMED_ISTORAGE:
+	{
+	    if (pmedium->u.pstg != 0)
+		IStorage_Release(pmedium->u.pstg);
+
+	    pmedium->u.pstg = 0;
+	    break;
+	}
+	case TYMED_GDI:
+	{
+	    if ( (pmedium->pUnkForRelease == 0) && (pmedium->u.hGlobal != 0) )
+		DeleteObject(pmedium->u.hGlobal);
+
+	    pmedium->u.hGlobal = 0;
+	    break;
+	}
+	case TYMED_MFPICT:
+	{
+	    if ( (pmedium->pUnkForRelease == 0) && (pmedium->u.hMetaFilePict != 0) )
+	    {
+		DeleteMetaFile(pmedium->u.hMetaFilePict);
+		GlobalFree(pmedium->u.hMetaFilePict);
+	    }
+
+	    pmedium->u.hMetaFilePict = 0;
+	    break;
+	}
+	case TYMED_ENHMF:
+	{
+	    if ( (pmedium->pUnkForRelease == 0) && (pmedium->u.hEnhMetaFile != 0) )
+		DeleteEnhMetaFile(pmedium->u.hEnhMetaFile);
+
+	    pmedium->u.hEnhMetaFile = 0;
+	    break;
+	}
+	case TYMED_NULL:
+	    // Do nothing
+	    break;
+
+	default:
+	    break;
     }
 
@@ -477,12 +477,12 @@
     if (pmedium->pUnkForRelease != 0)
     {
-  IUnknown_Release(pmedium->pUnkForRelease);
-  pmedium->pUnkForRelease = 0;
-    }
-}
-
-// ======================================================================
+	IUnknown_Release(pmedium->pUnkForRelease);
+	pmedium->pUnkForRelease = 0;
+    }
+}
+
+// ====================================================================== 
 // Private functions.
-// ======================================================================
+// ====================================================================== 
 
 /***
@@ -495,5 +495,5 @@
  * params:
  *     regKey   - Key to read the default value from
- *     pdwValue - Pointer to the location where the DWORD
+ *     pdwValue - Pointer to the location where the DWORD 
  *                value is returned. This value is not modified
  *                if the value is not found.
@@ -501,5 +501,5 @@
 
 static void OLEUTL_ReadRegistryDWORDValue(
-  HKEY   regKey,
+  HKEY   regKey, 
   DWORD* pdwValue)
 {
@@ -510,9 +510,9 @@
 
   lres = RegQueryValueExA(regKey,
-        "",
-        NULL,
-        &dwKeyType,
-        (LPBYTE)buffer,
-        &cbData);
+			  "",
+			  NULL,
+			  &dwKeyType,
+			  (LPBYTE)buffer,
+			  &cbData);
 
   if (lres == ERROR_SUCCESS)
@@ -521,11 +521,11 @@
     {
       case REG_DWORD:
-  *pdwValue = *(DWORD*)buffer;
-  break;
+	*pdwValue = *(DWORD*)buffer;
+	break;
       case REG_EXPAND_SZ:
       case REG_MULTI_SZ:
       case REG_SZ:
-  *pdwValue = (DWORD)strtoul(buffer, NULL, 10);
-  break;
+	*pdwValue = (DWORD)strtoul(buffer, NULL, 10);
+	break;
     }
   }
