Index: /trunk/src/VBox/Installer/win/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Installer/win/Makefile.kmk	(revision 48322)
+++ /trunk/src/VBox/Installer/win/Makefile.kmk	(revision 48323)
@@ -419,4 +419,5 @@
 			$(PATH_SUB_CURRENT)/UserInterface.wxi \
 			$(VBOX_WIN_INST_OUT_DIR)/VirtualBox_TypeLib.wxi \
+			$(if $(VBOX_WITH_32_ON_64_MAIN_API),$(VBOX_WIN_INST_OUT_DIR)/VirtualBox_TypeLib_x86.wxi,) \
 			$(VBOX_WIN_INST_OUT_DIR)/VBoxKey.wxi \
 			$(VBOX_WIN_INST_OUT_DIR)/VBoxGuiNLS.wxi \
@@ -447,4 +448,5 @@
 		-E 'VBOX_SIGNING_MODE=$(strip $(if $(VBOX_SIGNING_MODE),$(VBOX_SIGNING_MODE),none))' \
 		-E 'VBOX_GUI_USE_QGL=$(if $(VBOX_GUI_USE_QGL),yes,no)' \
+		-E 'VBOX_WITH_32_ON_64_MAIN_API=$(if $(VBOX_WITH_32_ON_64_MAIN_API),yes,no)' \
 		-E 'VBOX_WITH_ADDITIONS_PACKING=$(if $(VBOX_WITH_ADDITIONS_PACKING),yes,no)' \
 		-E 'VBOX_WITH_COMBINED_PACKAGE=$(if $(VBOX_WITH_COMBINED_PACKAGE),yes,no)' \
@@ -501,4 +503,13 @@
 	$(VBOX_XSLTPROC) -o $@ $< $(VBOX_XIDL_FILE)
 
+$(VBOX_WIN_INST_OUT_DIR)/VirtualBox_TypeLib_x86.wxi: \
+		$(PATH_SUB_CURRENT)/VirtualBox_TypeLib.xsl \
+		$(VBOX_XIDL_FILE) \
+		| $$(dir $$@)
+	$(VBOX_XSLTPROC) --stringparam "a_sTarget" "VBoxClient-x86"  -o $@.tmp $< $(VBOX_XIDL_FILE)
+	$(SED) -e 's/VBoxC/VBoxClient_x86/g' --output $@ $@.tmp
+	$(RM) -f $@.tmp
+
+
 #
 # Construct the list of GUI translations.
Index: /trunk/src/VBox/Installer/win/VirtualBox.wxs
===================================================================
--- /trunk/src/VBox/Installer/win/VirtualBox.wxs	(revision 48322)
+++ /trunk/src/VBox/Installer/win/VirtualBox.wxs	(revision 48323)
@@ -334,4 +334,14 @@
                         </Component>
                     </Directory>
+
+<?if $(env.VBOX_WITH_32_ON_64_MAIN_API) = "yes" ?>
+                    <!-- The 32-bit client COM component (see also cp_MainCom below). -->
+                    <Component Id="cp_MainCOM_x86" Guid="B600824E-4A25-2EB3-4B44-3D8CB7F9B92D" Win64="no">
+                        <File Id="VBoxClient_x86" Name="VBoxClient-x86.dll"
+                            Source="$(env.PATH_OUT)\bin\VBoxClient-x86.dll" KeyPath="yes">
+                        </File>
+                        <?include $(env.PATH_TARGET)\VirtualBox_TypeLib_x86.wxi ?>
+                    </Component>
+<?endif?>
 
                     <!-- COM components have a separate entry mainly because of the KeyPath attribute (that hints the
@@ -696,4 +706,7 @@
 <?endif?>
             <ComponentRef Id="cp_NLS" />
+<?if $(env.VBOX_WITH_32_ON_64_MAIN_API) = "yes" ?>
+            <ComponentRef Id="cp_MainCOM_x86" />
+<?endif?>
             <ComponentRef Id="cp_MainCOM" />
             <ComponentRef Id="cp_MainBinaries" />
Index: /trunk/src/VBox/Installer/win/VirtualBox_TypeLib.xsl
===================================================================
--- /trunk/src/VBox/Installer/win/VirtualBox_TypeLib.xsl	(revision 48322)
+++ /trunk/src/VBox/Installer/win/VirtualBox_TypeLib.xsl	(revision 48323)
@@ -27,4 +27,6 @@
 <xsl:strip-space elements="*"/>
 
+<xsl:param name="a_sTarget">all</xsl:param>
+
 
 <!--
@@ -46,4 +48,5 @@
  *  Source    : src/VBox/Main/idl/VirtualBox.xidl
  *  Generator : src/VBox/Installer/VirtualBox_TypeLib.xsl
+ *  Arguments : a_sTarget=<xsl:value-of select="$a_sTarget"/>
  */
   </xsl:comment>
@@ -67,5 +70,12 @@
         <xsl:attribute name="Id"><xsl:value-of select="@appUuid"/></xsl:attribute>
         <xsl:attribute name="Description"><xsl:value-of select="@name"/> Application</xsl:attribute>
-        <xsl:apply-templates select="module/class"/>
+        <xsl:choose>
+          <xsl:when test="$a_sTarget = 'VBoxClient-x86'">
+            <xsl:apply-templates select="module[@name='VBoxC']/class"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates select="module/class"/>
+          </xsl:otherwise>
+        </xsl:choose>
       </AppId>
     </TypeLib>
Index: /trunk/src/VBox/Main/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Main/Makefile.kmk	(revision 48322)
+++ /trunk/src/VBox/Main/Makefile.kmk	(revision 48323)
@@ -744,8 +744,20 @@
  # 32-bit VBox API Client In-Process module.
  #
+ # This is currently just a 32-bit version of VBoxC.  It might be desirable to
+ # split up VBoxC into a simple client and a VM client part later, in which
+ # case this module will be a simple client.
+ #
+ # Note! One important thing is that the typelib for this DLL must be build
+ #       with the /env win32 switch and the VBoxC typelib with /env amd64, if
+ #       not they will overwrite each others typelib module entry.
+ #
  DLLS += VBoxClient-x86
  VBoxClient-x86_TEMPLATE = VBoxMainComp-x86
  VBoxClient-x86_EXTENDS  = VBoxC
  VBoxClient-x86_DEFS = VBOX_COM_INPROC_API_CLIENT $(VBoxC_DEFS)
+ VBoxClient-x86_INCS.win = \
+ 	$(VBoxClient-x86_0_OUTDIR) \
+ 	$(VBoxCOM-x86_0_OUTDIR) \
+	$(VBoxC_INCS.win)
  VBoxClient-x86_SOURCES = \
  	src-all/EventImpl.cpp \
@@ -760,6 +772,6 @@
  VBoxClient-x86_SOURCES.win = \
  	src-client/win/dllmain.cpp \
- 	src-client/win/VBoxC.def \
- 	src-client/win/VBoxC.rc
+ 	src-client/win/VBoxClient-x86.def \
+ 	src-client/win/VBoxClient-x86.rc
  ifdef VBOX_WITH_XPCOM
   VBoxClient-x86_SOURCES += \
@@ -767,4 +779,15 @@
  endif
  VBoxClient-x86_LIBS = $(NO_SUCH_VARIABLE)
+ VBoxClient-x86_LIBS.win = $(NO_SUCH_VARIABLE)
+ VBoxClient-x86_CLEAN.win += $$(VBoxClient-x86_0_OUTDIR)/VBoxClient-x86.rgs
+ src-client/win/VBoxClient-x86.rc_DEPS = \
+ 	$(VBoxClient-x86_0_OUTDIR)/VBoxClient-x86.rgs \
+ 	$(VBoxCOM-x86_0_OUTDIR)/VirtualBox-x86.tlb
+
+ $$(VBoxClient-x86_0_OUTDIR)/VBoxClient-x86.rgs: \
+ 		$(VBOX_PATH_MAIN_SRC)/src-all/win/VirtualBox_rgs.xsl \
+		$(VBOX_XIDL_FILE) | $$(dir $$@)
+	$(VBOX_XSLTPROC) --stringparam Module VBoxC -o $@ $< $(VBOX_XIDL_FILE)
+
 endif
 
@@ -788,7 +811,7 @@
 	include
 ifeq ($(KBUILD_TARGET),win)
- VBoxCOM_DEFS.x86      += _WIN32_WINNT=0x0500
- VBoxCOM_DEFS.amd64    += _WIN32_WINNT=0x0510
- VBoxCOM_SOURCES       += \
+ VBoxCOM_DEFS.x86       = _WIN32_WINNT=0x0500
+ VBoxCOM_DEFS.amd64     = _WIN32_WINNT=0x0510
+ VBoxCOM_SOURCES.win    = \
 	$(VBoxCOM_0_OUTDIR)/VirtualBox_i.c
 else # !win
@@ -805,4 +828,6 @@
  VBoxCOM-x86_TEMPLATE = VBoxMainLib-x86
  VBoxCOM-x86_EXTENDS  = VBoxCOM
+ VBoxCOM-x86_SOURCES.win    = \
+	$(VBoxCOM-x86_0_OUTDIR)/VirtualBox_i.c
 endif
 
@@ -887,5 +912,6 @@
 testidlhdr: $(VBOX_IDL_HEADER.XPCOM)
 else
-testidl:    $(VBOX_IDL_FILE.MSCOM) $(VBoxCOM_0_OUTDIR)/VirtualBox_i.c
+testidl:    $(VBOX_IDL_FILE.MSCOM) $(VBoxCOM_0_OUTDIR)/VirtualBox_i.c \
+	$(if $(VBOX_WITH_32_ON_64_MAIN_API),$(VBoxCOM-x86_0_OUTDIR)/VirtualBox_i.c,)
 endif
 
@@ -894,7 +920,18 @@
 + $(VBoxCOM_0_OUTDIR)/VirtualBox.h \
 + $(VBoxCOM_0_OUTDIR)/VirtualBox.tlb: $(VBOX_IDL_FILE.MSCOM) | $$(dir $$@)
-	$(VBOX_WIN_MIDL) /nologo \
+	$(VBOX_WIN_MIDL) /nologo $(if-expr "$(KBUILD_TARGET_ARCH)" == "amd64",/env amd64,/env win32) /target NT51 \
 		/out $(call VBOX_FN_MAKE_WIN_PATH,$(VBoxCOM_0_OUTDIR)) \
 		/cpp_cmd $(subst $(EXEC_X86_WIN32),,$(call VBOX_FN_MAKE_WIN_PATH,$(TOOL_$(VBOX_VCC_TOOL)_CC))) \
+		/I $(call VBOX_FN_MAKE_WIN_PATH,$(PATH_SDK_$(VBOX_WINPSDK)_INC)) \
+		/I idl \
+		$(call VBOX_FN_MAKE_WIN_PATH,$<)
+
+$(VBoxCOM-x86_0_OUTDIR)/VirtualBox_i.c \
++ $(VBoxCOM-x86_0_OUTDIR)/VirtualBox.h \
++ $(VBoxCOM-x86_0_OUTDIR)/VirtualBox-x86.tlb: $(VBOX_IDL_FILE.MSCOM) | $$(dir $$@)
+	$(VBOX_WIN_MIDL) /nologo /env win32 /target NT51 \
+		/out $(call VBOX_FN_MAKE_WIN_PATH,$(VBoxCOM-x86_0_OUTDIR)) \
+		/tlb $(call VBOX_FN_MAKE_WIN_PATH,$(VBoxCOM-x86_0_OUTDIR)/VirtualBox-x86.tlb) \
+		/cpp_cmd $(subst $(EXEC_X86_WIN32),,$(call VBOX_FN_MAKE_WIN_PATH,$(TOOL_$(VBOX_VCC_TOOL_STEM)X86_CC))) \
 		/I $(call VBOX_FN_MAKE_WIN_PATH,$(PATH_SDK_$(VBOX_WINPSDK)_INC)) \
 		/I idl \
Index: /trunk/src/VBox/Main/src-all/win/comregister.cmd
===================================================================
--- /trunk/src/VBox/Main/src-all/win/comregister.cmd	(revision 48322)
+++ /trunk/src/VBox/Main/src-all/win/comregister.cmd	(revision 48323)
@@ -7,5 +7,5 @@
 
 REM
-REM Copyright (C) 2006-2011 Oracle Corporation
+REM Copyright (C) 2006-2013 Oracle Corporation
 REM
 REM This file is part of VirtualBox Open Source Edition (OSE), as
@@ -95,12 +95,30 @@
 REM Do the registrations.
 REM
-:register
+if "%ProgramW6432%x" == "x" goto register_x86
+goto register_amd64
+
+:register_x86
 @echo on
-%_VBOX_DIR%VBoxSVC.exe /ReregServer
+%_VBOX_DIR%VBoxSVC.exe /UnregServer
 regsvr32 /s /u %_VBOX_DIR%VBoxC.dll
+@if "%1" == "-u" goto end
+%_VBOX_DIR%VBoxSVC.exe /RegServer
 regsvr32 /s    %_VBOX_DIR%VBoxC.dll
+@echo off
+goto end
+
+REM Unregister both first, then register them. The order matters here.
+:register_amd64
+@echo on
+%_VBOX_DIR%VBoxSVC.exe /UnregServer
+%windir%\syswow64\regsvr32 /s /u %_VBOX_DIR%VBoxClient-x86.dll
+%windir%\system32\regsvr32 /s /u %_VBOX_DIR%VBoxC.dll
+@if "%1" == "-u" goto end
+%_VBOX_DIR%VBoxSVC.exe /RegServer
+%windir%\system32\regsvr32 /s    %_VBOX_DIR%VBoxC.dll
+%windir%\syswow64\regsvr32 /s    %_VBOX_DIR%VBoxClient-x86.dll
 @echo off
 
 :end
-endlocal
+@endlocal
 
Index: /trunk/src/VBox/Main/src-client/win/VBoxClient-x86.def
===================================================================
--- /trunk/src/VBox/Main/src-client/win/VBoxClient-x86.def	(revision 48323)
+++ /trunk/src/VBox/Main/src-client/win/VBoxClient-x86.def	(revision 48323)
@@ -0,0 +1,26 @@
+; $Id$
+;; @file
+; VBoxClient-x86 DLL Definition File.
+;
+
+;
+; Copyright (C) 2006-2013 Oracle Corporation
+;
+; This file is part of VirtualBox Open Source Edition (OSE), as
+; available from http://www.virtualbox.org. This file is free software;
+; you can redistribute it and/or modify it under the terms of the GNU
+; General Public License (GPL) as published by the Free Software
+; Foundation, in version 2 as it comes in the "COPYING" file of the
+; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+;
+
+LIBRARY VBoxClient-x86.dll
+
+EXPORTS
+    ; COM entry points
+    DllGetClassObject   PRIVATE
+    DllCanUnloadNow     PRIVATE
+    DllRegisterServer   PRIVATE
+    DllUnregisterServer PRIVATE
+
Index: /trunk/src/VBox/Main/src-client/win/VBoxClient-x86.rc
===================================================================
--- /trunk/src/VBox/Main/src-client/win/VBoxClient-x86.rc	(revision 48323)
+++ /trunk/src/VBox/Main/src-client/win/VBoxClient-x86.rc	(revision 48323)
@@ -0,0 +1,67 @@
+/* $Id$ */
+/** @file
+ * VBoxC - Resource file containing version info and icon.
+ */
+
+/*
+ * Copyright (C) 2006-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include <windows.h>
+#include <VBox/version.h>
+
+#include "win/resource.h"
+
+VS_VERSION_INFO    VERSIONINFO
+  FILEVERSION      VBOX_VERSION_MAJOR_NR,VBOX_VERSION_MINOR_NR,VBOX_VERSION_BUILD_NR,0
+  PRODUCTVERSION   VBOX_VERSION_MAJOR_NR,VBOX_VERSION_MINOR_NR,VBOX_VERSION_BUILD_NR,0
+  FILEFLAGSMASK    VS_FFI_FILEFLAGSMASK
+#ifdef _DEBUG
+  FILEFLAGS        VS_FF_DEBUG|VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE
+#else
+  FILEFLAGS        0 // final version
+#endif
+  FILEOS           VOS__WINDOWS32
+  FILETYPE         VFT_DLL
+  FILESUBTYPE      0   // not used
+BEGIN
+  BLOCK "StringFileInfo"
+  BEGIN
+    BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
+    BEGIN
+    VALUE "CompanyName",     VBOX_RC_COMPANY_NAME
+    VALUE "FileDescription", "VirtualBox Interface (32-bit)\0"
+    VALUE "FileVersion",     VBOX_VERSION_MAJOR "." VBOX_VERSION_MINOR "." VBOX_VERSION_BUILD "." VBOX_SVN_REV "\0"
+    VALUE "InternalName",    "VBoxClient-x86.dll\0"
+    VALUE "LegalCopyright",  VBOX_RC_LEGAL_COPYRIGHT
+    VALUE "OriginalFilename","VBoxClient-x86.dll\0"
+    VALUE "ProductName",     VBOX_PRODUCT "\0"
+    VALUE "ProductVersion",  VBOX_VERSION_MAJOR "." VBOX_VERSION_MINOR "." VBOX_VERSION_BUILD ".r" VBOX_SVN_REV "\0"
+
+    VALUE "OLESelfRegister", ""
+
+    END
+  END
+  BLOCK "VarFileInfo"
+  BEGIN
+    VALUE "Translation", 0x409, 1252
+  END
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_VIRTUALBOX REGISTRY "VBoxClient-x86.rgs"
+
+1 TYPELIB "VirtualBox-x86.tlb"
+
Index: /trunk/src/VBox/Main/src-client/win/dllmain.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/win/dllmain.cpp	(revision 48322)
+++ /trunk/src/VBox/Main/src-client/win/dllmain.cpp	(revision 48323)
@@ -32,4 +32,8 @@
 #include <iprt/string.h>
 
+
+/*******************************************************************************
+*   Global Variables                                                           *
+*******************************************************************************/
 CComModule _Module;
 
@@ -40,8 +44,41 @@
 
 
+/** @def WITH_MANUAL_CLEANUP
+ * Manually clean up the registry. */
+#if defined(DEBUG) && !defined(VBOX_IN_32_ON_64_MAIN_API)
+//# define WITH_MANUAL_CLEANUP
+#endif
+
+
+#ifndef WITH_MANUAL_CLEANUP
+/** Type library GUIDs to clean up manually. */
+static const char * const g_apszTypelibGuids[] =
+{
+    "{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}",
+    "{d7569351-1750-46f0-936e-bd127d5bc264}",
+};
+
+/** Same as above but with a "Typelib\\" prefix. */
+static const char * const g_apszTypelibGuidKeys[] =
+{
+    "TypeLib\\{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}",
+    "TypeLib\\{d7569351-1750-46f0-936e-bd127d5bc264}",
+};
+
+/** Type library version to clean up manually. */
+static const char * const g_apszTypelibVersions[] =
+{
+    "1.0",
+    "1.3",
+};
+#endif
+
+
 /*******************************************************************************
 *   Internal Functions                                                         *
 *******************************************************************************/
+#ifndef WITH_MANUAL_CLEANUP
 static void removeOldMess(void);
+#endif
 
 
@@ -89,5 +126,4 @@
 {
     // registers object, typelib and all interfaces in typelib
-    removeOldMess();
     return _Module.RegisterServer(TRUE);
 }
@@ -98,12 +134,118 @@
 STDAPI DllUnregisterServer(void)
 {
-    return _Module.UnregisterServer(TRUE);
-}
-
-
-
-/**
- * Hack to clean out the interfaces belonging to the old typelib on development
+    HRESULT hrc = _Module.UnregisterServer(TRUE);
+#ifndef WITH_MANUAL_CLEANUP
+    removeOldMess();
+#endif
+    return hrc;
+}
+
+#ifndef WITH_MANUAL_CLEANUP
+
+/**
+ * Checks if the typelib GUID is one of the ones we wish to clean up.
+ *
+ * @returns true if it should be cleaned up, false if not.
+ * @param   pszTypelibGuid  The typelib GUID as bracketed string.
+ */
+static bool isTypelibGuidToRemove(const char *pszTypelibGuid)
+{
+    unsigned i = RT_ELEMENTS(g_apszTypelibGuids);
+    while (i-- > 0)
+        if (!stricmp(g_apszTypelibGuids[i], pszTypelibGuid))
+            return true;
+    return false;
+}
+
+
+/**
+ * Checks if the typelib version is one of the ones we wish to clean up.
+ *
+ * @returns true if it should be cleaned up, false if not.
+ * @param   pszTypelibVer   The typelib version as string.
+ */
+static bool isTypelibVersionToRemove(const char *pszTypelibVer)
+{
+    unsigned i = RT_ELEMENTS(g_apszTypelibVersions);
+    while (i-- > 0)
+        if (!strcmp(g_apszTypelibVersions[i], pszTypelibVer))
+            return true;
+    return false;
+}
+
+
+/**
+ * Hack to clean out the class IDs belonging to obsolete typelibs on development
  * boxes and such likes.
+ */
+static void removeOldClassIDs(HKEY hkeyClassesRoot)
+{
+    HKEY hkeyClsId;
+    LONG rc = RegOpenKeyExA(hkeyClassesRoot, "CLSID", NULL, DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE,
+                            &hkeyClsId);
+    if (rc == ERROR_SUCCESS)
+    {
+        for (DWORD idxKey = 0;; idxKey++)
+        {
+            char szCurNm[128 + 128];
+            DWORD cbCurNm = 128;
+            rc = RegEnumKeyExA(hkeyClsId, idxKey, szCurNm, &cbCurNm, NULL, NULL, NULL, NULL);
+            if (rc == ERROR_NO_MORE_ITEMS)
+                break;
+
+            /*
+             * Get the typelib GUID and program ID with the class ID.
+             */
+            AssertBreak(rc == ERROR_SUCCESS);
+            strcpy(&szCurNm[cbCurNm], "\\TypeLib");
+            HKEY hkeyIfTypelib;
+            rc = RegOpenKeyExA(hkeyClsId, szCurNm, NULL, KEY_QUERY_VALUE, &hkeyIfTypelib);
+            if (rc != ERROR_SUCCESS)
+                continue;
+
+            char szTypelibGuid[128];
+            DWORD cbValue = sizeof(szTypelibGuid) - 1;
+            rc = RegQueryValueExA(hkeyIfTypelib, NULL, NULL, NULL, (PBYTE)&szTypelibGuid[0], &cbValue);
+            if (rc != ERROR_SUCCESS)
+                cbValue = 0;
+            szTypelibGuid[cbValue] = '\0';
+            RegCloseKey(hkeyIfTypelib);
+            if (!isTypelibGuidToRemove(szTypelibGuid))
+                continue;
+
+            /* ProgId */
+            strcpy(&szCurNm[cbCurNm], "\\ProgId");
+            HKEY hkeyIfProgId;
+            rc = RegOpenKeyExA(hkeyClsId, szCurNm, NULL, KEY_QUERY_VALUE, &hkeyIfProgId);
+            if (rc != ERROR_SUCCESS)
+                continue;
+
+            char szProgId[64];
+            cbValue = sizeof(szProgId) - 1;
+            rc = RegQueryValueExA(hkeyClsId, NULL, NULL, NULL, (PBYTE)&szProgId[0], &cbValue);
+            if (rc != ERROR_SUCCESS)
+                cbValue = 0;
+            szProgId[cbValue] = '\0';
+            RegCloseKey(hkeyClsId);
+            if (strnicmp(szProgId, RT_STR_TUPLE("VirtualBox.")))
+                continue;
+
+            /*
+             * Ok, it's an orphaned VirtualBox interface. Delete it.
+             */
+            szCurNm[cbCurNm] = '\0';
+            RTAssertMsg2("Should delete HCR/CLSID/%s\n", szCurNm);
+            //rc = SHDeleteKeyA(hkeyClsId, szCurNm);
+            Assert(rc == ERROR_SUCCESS);
+        }
+
+        RegCloseKey(hkeyClsId);
+    }
+}
+
+
+/**
+ * Hack to clean out the interfaces belonging to obsolete typelibs on
+ * development boxes and such likes.
  */
 static void removeOldInterfaces(HKEY hkeyClassesRoot)
@@ -138,5 +280,5 @@
                 cbValue = 0;
             szTypelibGuid[cbValue] = '\0';
-            if (strcmp(szTypelibGuid, "{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}"))
+            if (!isTypelibGuidToRemove(szTypelibGuid))
             {
                 RegCloseKey(hkeyIfTypelib);
@@ -153,5 +295,5 @@
             RegCloseKey(hkeyIfTypelib);
 
-            if (strcmp(szTypelibVer, "1.3"))
+            if (!isTypelibVersionToRemove(szTypelibVer))
                 continue;
 
@@ -172,5 +314,5 @@
 
 /**
- * Hack to clean out the old typelib on development boxes and such.
+ * Hack to clean obsolete typelibs on development boxes and such.
  */
 static void removeOldTypelib(HKEY hkeyClassesRoot)
@@ -179,49 +321,57 @@
      * Open it and verify the identity.
      */
-    HKEY hkeyOldTyplib;
-    LONG rc = RegOpenKeyExA(hkeyClassesRoot, "TypeLib\\{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}", NULL,
-                            DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &hkeyOldTyplib);
-    if (rc == ERROR_SUCCESS)
-    {
-        HKEY hkeyVer1Dot3;
-        rc = RegOpenKeyExA(hkeyOldTyplib, "1.3", NULL, KEY_READ, &hkeyVer1Dot3);
+    unsigned i = RT_ELEMENTS(g_apszTypelibGuidKeys);
+    while (i-- > 0)
+    {
+        HKEY hkeyTyplib;
+        LONG rc = RegOpenKeyExA(hkeyClassesRoot, g_apszTypelibGuidKeys[i], NULL,
+                                DELETE | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &hkeyTyplib);
         if (rc == ERROR_SUCCESS)
         {
-            char szValue[128];
-            DWORD cbValue = sizeof(szValue) - 1;
-            rc = RegQueryValueExA(hkeyVer1Dot3, NULL, NULL, NULL, (PBYTE)&szValue[0], &cbValue);
-            if (rc == ERROR_SUCCESS)
+            unsigned iVer = RT_ELEMENTS(g_apszTypelibVersions);
+            while (iVer-- > 0)
             {
-                szValue[cbValue] = '\0';
-                if (!strcmp(szValue, "VirtualBox Type Library"))
+                HKEY hkeyVer;
+                rc = RegOpenKeyExA(hkeyTyplib, g_apszTypelibVersions[iVer], NULL, KEY_READ, &hkeyVer);
+                if (rc == ERROR_SUCCESS)
                 {
-                    RegCloseKey(hkeyVer1Dot3);
-                    hkeyVer1Dot3 = NULL;
-
-                    /*
-                     * Delete the type library.
-                     */
-                    //RTAssertMsg2("Should delete HCR/TypeLib/{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}/1.3\n");
-                    rc = SHDeleteKeyA(hkeyOldTyplib, "1.3");
-                    Assert(rc == ERROR_SUCCESS);
+                    char szValue[128];
+                    DWORD cbValue = sizeof(szValue) - 1;
+                    rc = RegQueryValueExA(hkeyVer, NULL, NULL, NULL, (PBYTE)&szValue[0], &cbValue);
+                    if (rc == ERROR_SUCCESS)
+                    {
+                        szValue[cbValue] = '\0';
+                        if (!strcmp(szValue, "VirtualBox Type Library"))
+                        {
+                            RegCloseKey(hkeyVer);
+                            hkeyVer = NULL;
+
+                            /*
+                             * Delete the type library.
+                             */
+                            //RTAssertMsg2("Should delete HCR\\%s\\%s\n", g_apszTypelibGuidKeys[i], g_apszTypelibVersions[iVer]);
+                            rc = SHDeleteKeyA(hkeyTyplib, g_apszTypelibVersions[iVer]);
+                            Assert(rc == ERROR_SUCCESS);
+                        }
+                    }
+
+                    if (hkeyVer != NULL)
+                        RegCloseKey(hkeyVer);
                 }
             }
-
-            if (hkeyVer1Dot3 != NULL)
-                RegCloseKey(hkeyVer1Dot3);
+            RegCloseKey(hkeyTyplib);
+
+            /*
+             * The typelib key should be empty now, so we can try remove it (non-recursively).
+             */
+            rc = RegDeleteKeyA(hkeyClassesRoot, g_apszTypelibGuidKeys[i]);
+            Assert(rc == ERROR_SUCCESS);
         }
-        RegCloseKey(hkeyOldTyplib);
-
-        /*
-         * The typelib key should be empty now, so we can try remove it (non-recursively).
-         */
-        rc = RegDeleteKeyA(hkeyClassesRoot, "TypeLib\\{46137EEC-703B-4FE5-AFD4-7C9BBBBA0259}");
-        Assert(rc == ERROR_SUCCESS);
-    }
-}
-
-
-/**
- * Hack to clean out the old typelib on development boxes and such.
+    }
+}
+
+
+/**
+ * Hack to clean out obsolete typelibs on development boxes and such.
  */
 static void removeOldMess(void)
@@ -232,4 +382,5 @@
     removeOldTypelib(HKEY_CLASSES_ROOT);
     removeOldInterfaces(HKEY_CLASSES_ROOT);
+    removeOldClassIDs(HKEY_CLASSES_ROOT);
 
     /*
@@ -243,4 +394,5 @@
         removeOldTypelib(hkeyWow64);
         removeOldInterfaces(hkeyWow64);
+        removeOldClassIDs(hkeyWow64);
 
         RegCloseKey(hkeyWow64);
@@ -248,2 +400,4 @@
 }
 
+#endif /* WITH_MANUAL_CLEANUP */
+
