[ooo-build-commit] Branch 'ooo/OOO320' - extensions/prj extensions/source setup_native/prj setup_native/source

Jan Holesovsky kendy at kemper.freedesktop.org
Fri Nov 20 17:29:36 PST 2009


 extensions/prj/d.lst                                                        |    1 
 extensions/source/activex/main/SOActiveX.cpp                                |    2 
 extensions/source/activex/main/SOComWindowPeer.h                            |    2 
 extensions/source/activex/main/makefile.mk                                  |   55 +
 extensions/source/activex/main/so_activex.cpp                               |  383 +++++---
 setup_native/prj/build.lst                                                  |    1 
 setup_native/source/win32/customactions/reg64/exports.dxp                   |    2 
 setup_native/source/win32/customactions/reg64/makefile.mk                   |  112 ++
 setup_native/source/win32/customactions/reg64/reg64.cxx                     |  474 ++++++++++
 setup_native/source/win32/customactions/regactivex/regactivex.cxx           |   50 -
 setup_native/source/win32/customactions/shellextensions/shellextensions.cxx |   93 +
 11 files changed, 1011 insertions(+), 164 deletions(-)

New commits:
commit 076d6f676d81e6f4c275bb7097ade86f5515df31
Author: Ivo Hinkelmann <ihi at openoffice.org>
Date:   Fri Nov 20 13:56:43 2009 +0000

    CWS-TOOLING: integrate CWS tkr28
    2009-11-12 15:21:09 +0100 tkr  r277479 : #i105892# install ifilter for x64 and x86
    2009-11-11 07:39:36 +0100 tkr  r277439 : #105892# declare RegDeleteKeyExA  for mingw
    2009-11-11 07:38:38 +0100 tkr  r277438 : #105892# define KEY_WOW64_64KEY for mingw
    2009-11-10 10:43:56 +0100 tkr  r277422 : #105892# define KEY_WOW64_64KEY for mingw
    2009-11-10 08:41:11 +0100 tkr  r277419 : #105892# define KEY_WOW64_64KEY for mingw
    2009-11-10 08:38:52 +0100 tkr  r277418 : #105892# define KEY_WOW64_64KEY for mingw
    2009-11-10 08:31:09 +0100 tkr  r277417 : #105892# define KEY_WOW64_64KEY for mingw
    2009-11-09 10:08:42 +0100 tkr  r277403 : #105892# define KEY_WOW64_64KEY for mingw
    2009-11-06 14:10:13 +0100 tkr  r277386 : #105892# define KEY_WOW64_64KEY for mingw
    2009-11-06 14:08:29 +0100 tkr  r277384 : #105892# define KEY_WOW64_64KEY for mingw
    2009-11-06 12:09:12 +0100 tkr  r277381 : #105892# new BUILD_X64 variable for wntmsci12
    2009-11-03 14:44:33 +0100 mav  r277321 : #i106476# support 64-bit IE
    2009-11-03 11:53:01 +0100 mav  r277317 : #i106476# support 64-bit IE
    2009-11-03 11:50:31 +0100 mav  r277316 : #i106476# support 64-bit IE
    2009-11-03 10:09:46 +0100 mav  r277313 : #i106476# support 64-bit IE
    2009-11-02 22:21:20 +0100 mav  r277306 : #i106476# support 64-bit IE
    2009-11-02 21:33:49 +0100 mav  r277305 : #i106476# support 64-bit IE
    2009-11-02 13:39:18 +0100 tkr  r277296 : #105892# adjust customaction conditions
    2009-11-02 13:38:02 +0100 tkr  r277295 : #105892# fix reg64 customaction deinstallation
    2009-11-02 12:23:50 +0100 dv  r277292 : #i106129# cygwin uses case sensitive file names
    2009-11-02 08:49:04 +0100 tkr  r277287 : #105892# fix reg64 customaction
    2009-11-01 09:08:16 +0100 tkr  r277283 : #105892# build selected modules in x64 too
    2009-11-01 09:05:59 +0100 tkr  r277282 : #105892# add new registry entries for x64
    2009-11-01 09:04:50 +0100 tkr  r277281 : #105892# add new registry entries for x64
    2009-11-01 09:02:07 +0100 tkr  r277280 : #105892# add new *_x64 libs to instset
    2009-11-01 09:00:51 +0100 tkr  r277279 : #105892# add new BUILD_X64 variable
    2009-11-01 08:59:16 +0100 tkr  r277278 : #105892# add new reg64 customaction
    2009-11-01 08:56:23 +0100 tkr  r277277 : #105892# deliver new x64 libs to solver and made the  client name of the ooofiltproxy depends to x86/x64 builds
    2009-10-30 15:56:01 +0100 mav  r277276 : #i106476# support 64-bit IE
    2009-10-30 15:44:28 +0100 mav  r277275 : #i106476# support 64-bit IE
    2009-10-30 15:43:50 +0100 mav  r277274 : #i106476# support 64-bit IE
    2009-10-30 15:35:58 +0100 dv  r277273 : #i106129# we might need the VCRedist_x64.exe for 64 bit windows
    2009-10-30 13:37:59 +0100 mav  r277267 : #i106476# support 64-bit IE
    2009-10-30 12:51:50 +0100 mav  r277264 : #i106476# support 64-bit IE
    2009-10-30 12:48:15 +0100 mav  r277263 : #i106476# support 64-bit IE
    2009-10-29 15:54:41 +0100 dv  r277255 : #i106129# Don't use debug system libraries until we fully support x64 on windows
    2009-10-29 15:49:54 +0100 dv  r277254 : #i106129# Some changes to support 64Bit Windows
    2009-10-23 13:34:10 +0200 obo  r277159 : #i105892# Windows 64 Bit support
    2009-10-23 13:23:30 +0200 obo  r277153 : #i105892# Windows 64 Bit support SLO->SLO_X64
    2009-10-23 13:15:57 +0200 obo  r277147 : #i105892# Windows 64 Bit support
    2009-10-23 13:12:07 +0200 obo  r277145 : #i105892# Windows 64 Bit support
    2009-10-23 13:04:07 +0200 is  r277143 : #i105892# preparing 64 bit Windows registry table
    2009-10-23 10:27:58 +0200 is  r277133 : #i105892# support for 64 bit registry in scp2

diff --git a/extensions/prj/d.lst b/extensions/prj/d.lst
index 053796a..ecfe0ef 100644
--- a/extensions/prj/d.lst
+++ b/extensions/prj/d.lst
@@ -20,6 +20,7 @@ mkdir: %_DEST%\bin%_EXT%\so
 ..\%__SRC%\bin\nsplugin %_DEST%\bin%_EXT%\nsplugin
 ..\%__SRC%\bin\npsoplugin.dll %_DEST%\bin%_EXT%\npsoplugin.dll
 ..\%__SRC%\bin\npsoplugin_so.dll %_DEST%\bin%_EXT%\so\npsoplugin.dll
+..\%__SRC%\bin\x64\so_activex.dll %_DEST%\bin%_EXT%\so_activex_x64.dll
 ..\%__SRC%\bin\mdibundle.zip %_DEST%\bin%_EXT%\mdibundle.zip
 
 ..\source\bibliography\uiconfig\sbibliography\menubar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\sbibliography\menubar\*.xml
diff --git a/extensions/source/activex/main/SOActiveX.cpp b/extensions/source/activex/main/SOActiveX.cpp
index 1e55ba0..feeda33 100644
--- a/extensions/source/activex/main/SOActiveX.cpp
+++ b/extensions/source/activex/main/SOActiveX.cpp
@@ -1025,6 +1025,7 @@ HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di )
             hr = CreateFrameOldWay( mOffWin,
                             di.prcBounds->right - di.prcBounds->left,
                             di.prcBounds->bottom - di.prcBounds->top );
+
             if( !SUCCEEDED( hr ) )
             {
                 // if the frame can not be opened do not try any more
@@ -1038,6 +1039,7 @@ HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di )
         {
             hr = LoadURLToFrame();
             mbLoad = FALSE;
+
             if( !SUCCEEDED( hr ) )
             {
                 // if the document can not be opened do not try any more
diff --git a/extensions/source/activex/main/SOComWindowPeer.h b/extensions/source/activex/main/SOComWindowPeer.h
index 27c6f40..55be8ca 100644
--- a/extensions/source/activex/main/SOComWindowPeer.h
+++ b/extensions/source/activex/main/SOComWindowPeer.h
@@ -55,7 +55,7 @@ DECLARE_REGISTRY_RESOURCEID(IDR_SOCOMWINDOWPEER)
             /* [in] */ short /*s*/,
             /* [retval][out] */ long __RPC_FAR *ret)
         {
-            *ret = (long) m_hwnd;
+            *ret = HandleToLong( m_hwnd );
             return S_OK;
         }
 
diff --git a/extensions/source/activex/main/makefile.mk b/extensions/source/activex/main/makefile.mk
index 64dcbe3..1a702eb 100644
--- a/extensions/source/activex/main/makefile.mk
+++ b/extensions/source/activex/main/makefile.mk
@@ -1,7 +1,7 @@
 #*************************************************************************
 #
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
+#
 # Copyright 2008 by Sun Microsystems, Inc.
 #
 # OpenOffice.org - a multi-platform office productivity suite
@@ -49,6 +49,10 @@ LIBTARGET=NO
 USE_DEFFILE=YES
 UWINAPILIB=
 
+.IF "$(BUILD_X64)"!=""
+USE_DEFFILE_X64=TRUE
+.ENDIF
+
 INCPRE+=$(foreach,i,$(ATL_INCLUDE) -I$(i)) \
     -I$(MISC) \
 
@@ -110,9 +114,58 @@ SHL1RES=$(RES)$/$(TARGET).res
 
 .ENDIF
 
+.IF "$(BUILD_X64)"!=""
+# -------------------- x64 -----------------------
+.IF "$(USE_STLP_DEBUG)"!=""
+CDEFS_X64+=-D_DEBUG
+.ENDIF # "$(USE_STLP_DEBUG)"!=""
+
+CDEFS_X64+:=$(foreach,i,$(CDEFS) $(subst,-D_X86_=1,  $i))
+LIBTARGET_X64=NO
+USE_DEFFILE_X64=YES
+UWINAPILIB_X64=
+
+SLOFILES_X64= \
+    $(SLO_X64)$/so_activex.obj \
+    $(SLO_X64)$/SOActiveX.obj \
+    $(SLO_X64)$/SOComWindowPeer.obj \
+    $(SLO_X64)$/SODispatchInterceptor.obj \
+    $(SLO_X64)$/SOActionsApproval.obj \
+    $(SLO_X64)$/StdAfx2.obj
+
+SHL1TARGET_X64=$(TARGET)
+
+SHL1STDLIBS_X64+=\
+    $(UUIDLIB_X64) \
+    $(ADVAPI32LIB_X64) \
+    $(OLE32LIB_X64) \
+    $(OLEAUT32LIB_X64) \
+    $(GDI32LIB_X64) \
+    $(URLMONLIB_X64) \
+    $(SHLWAPILIB_X64) \
+    $(KERNEL32LIB_X64) \
+    $(USER32LIB_X64) \
+    $(MSVCRT_X64) \
+    $(MSVCPRT_X64) \
+    $(OLDNAMESLIB_X64)
+
+SHL1OBJS_X64=$(SLOFILES_X64)
+SHL1DEF_X64=$(TARGET).def
+
+.IF "$(USE_STLP_DEBUG)" != ""
+    SHL1STDLIBS_X64+= $(ATL_LIB)$/amd64$/atlsd.lib
+.ELSE
+    SHL1STDLIBS_X64+= $(ATL_LIB)$/amd64$/atls.lib
+.ENDIF
+
+.ENDIF # "$(BUILD_X64)"!=""
+
 # --- Targets ----------------------------------
 
+.INCLUDE : set_wntx64.mk
+VERSIONOBJ_X64=
 .INCLUDE : target.mk
+.INCLUDE : tg_wntx64.mk
 
 $(MISC)$/envsettings.h : makefile.mk
     -$(RM) $@
diff --git a/extensions/source/activex/main/so_activex.cpp b/extensions/source/activex/main/so_activex.cpp
index 51a1db1..01f63dd 100644
--- a/extensions/source/activex/main/so_activex.cpp
+++ b/extensions/source/activex/main/so_activex.cpp
@@ -24,6 +24,30 @@ BEGIN_OBJECT_MAP(ObjectMap)
 OBJECT_ENTRY(CLSID_SOActiveX, CSOActiveX)
 END_OBJECT_MAP()
 
+
+#define X64_LIB_NAME "so_activex_x64.dll"
+#define X32_LIB_NAME "so_activex.dll"
+
+// 06.11.2009 tkr: to provide windows xp as build systems for mingw we need to define KEY_WOW64_64KEY
+// in mingw 3.13 KEY_WOW64_64KEY isn't available < Win2003 systems. 
+// Also defined in setup_native\source\win32\customactions\reg64\reg64.cxx,source\win32\customactions\shellextensions\shellextensions.cxx and
+// extensions\source\activex\main\so_activex.cpp
+#ifndef KEY_WOW64_64KEY
+    #define KEY_WOW64_64KEY	(0x0100)
+#endif
+
+const REGSAM n64KeyAccess = KEY_ALL_ACCESS | KEY_WOW64_64KEY;
+const REGSAM n32KeyAccess = KEY_ALL_ACCESS;
+
+#ifdef _AMD64_
+const BOOL bX64 = TRUE;
+#else
+const BOOL bX64 = FALSE;
+#endif
+
+// 10.11.2009 tkr: MinGW doesn't know anything about RegDeleteKeyExA if WINVER < 0x0502.
+WINADVAPI LONG WINAPI RegDeleteKeyExA(HKEY,LPCSTR,REGSAM,DWORD); 
+
 /////////////////////////////////////////////////////////////////////////////
 // DLL Entry Point
 
@@ -129,22 +153,23 @@ const char* aProxyStubActApprove = "{00020424-0000-0000-C000-000000000046}";
 // The following prefix is required for HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER ( not for HKEY_CLASSES_ROOT )
 const char* aLocalPrefix = "Software\\Classes\\";
 
-BOOL createKey( HKEY hkey, 
-                const char* aKeyToCreate, 
+BOOL createKey( HKEY hkey,
+                const char* aKeyToCreate,
+        REGSAM nKeyAccess,
                 const char* aValue = NULL, 
                 const char* aChildName = NULL, 
                 const char* aChildValue = NULL )
 {
     HKEY hkey1;
     
-    return ( ERROR_SUCCESS == RegCreateKey( hkey, aKeyToCreate, &hkey1 ) 
-           && ( !aValue || ERROR_SUCCESS == RegSetValueEx( hkey1, 
+    return ( ERROR_SUCCESS == RegCreateKeyExA( hkey, aKeyToCreate, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL ) 
+           && ( !aValue || ERROR_SUCCESS == RegSetValueExA( hkey1, 
                                                            "", 
                                                            0, 
                                                            REG_SZ, 
                                                            (const BYTE*)aValue, 
                                                            strlen( aValue ) ) )
-           && ( !aChildName || ERROR_SUCCESS == RegSetValueEx( hkey1, 
+           && ( !aChildName || ERROR_SUCCESS == RegSetValueExA( hkey1, 
                                                                aChildName, 
                                                                0, 
                                                                REG_SZ, 
@@ -154,8 +179,8 @@ BOOL createKey( HKEY hkey,
     
 }
 
-STDAPI DllUnregisterServerNative( int nMode, BOOL bForAllUsers );
-STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, const char* pActiveXPath )
+STDAPI DllUnregisterServerNative( int nMode, BOOL bForAllUsers, BOOL bFor64Bit );
+STDAPI DllRegisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess, const char* pProgramPath, const char* pLibName )
 {
     BOOL aResult = FALSE;
 
@@ -164,89 +189,86 @@ STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, const char* pActiv
     HKEY        hkey2 = NULL;
     HKEY        hkey3 = NULL;
     HKEY        hkey4 = NULL;
-    char        aSubKey[513];
+    char aSubKey[513];
     int         ind;
     const char* aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
 
-    char pActiveXPath101[1024];
-    char pPrCatalogPath[1019];
+    char pActiveXPath[1124];
+    char pActiveXPath101[1124];
 
     
     // In case SO7 is installed for this user he can have local registry entries that will prevent him from
     // using SO8 ActiveX control. The fix is just to clean up the local entries related to ActiveX control.
     // Unfortunately it can be done only for the user who installs the office.
     if ( bForAllUsers )
-        DllUnregisterServerNative( nMode, sal_False );
+        DllUnregisterServerNative( nMode, sal_False, sal_False );
 
 #ifdef MY_DEBUG
-    MessageBoxA(NULL, pActiveXPath, "Library Path, ( from library )", MB_OK | MB_ICONINFORMATION);
+    MessageBoxA(NULL, pProgramPath, "Library Path, ( from library )", MB_OK | MB_ICONINFORMATION);
 #endif
 
-    if ( pActiveXPath )
+    if ( pProgramPath && strlen( pProgramPath ) < 1024 )
     {
-        sprintf( pActiveXPath101, "%s, 101", pActiveXPath );
+        sprintf( pActiveXPath, "%s\\%s", pProgramPath, pLibName );
+        sprintf( pActiveXPath101, "%s\\%s, 101", pProgramPath, pLibName );
 
-        int nPrCatLength = strlen( pActiveXPath ) - sizeof( "so_activex.dll" ) + 1;
-        strncpy( pPrCatalogPath, pActiveXPath, nPrCatLength );
-        pPrCatalogPath[ nPrCatLength ] = 0;
-        
         {
-            wsprintf( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+            wsprintfA( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
             aResult = 
-                ( ERROR_SUCCESS == RegCreateKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey )
-                    && ERROR_SUCCESS == RegSetValueEx( hkey, "", 0, REG_SZ, (const BYTE*)"SOActiveX Class", 17 )
-                    && createKey( hkey, "Control" )
-                    && createKey( hkey, "EnableFullPage" )
-                    && createKey( hkey, "InprocServer32", pActiveXPath, "ThreadingModel", "Apartment" )
-                    && createKey( hkey, "MiscStatus", "0" )
-                    && createKey( hkey, "MiscStatus\\1", "131473" )
-                    && createKey( hkey, "ProgID", "so_activex.SOActiveX.1" )
-                    && createKey( hkey, "Programmable" )
-                    && createKey( hkey, "ToolboxBitmap32", pActiveXPath101 )
-                    && createKey( hkey, "TypeLib", aTypeLib )
-                    && createKey( hkey, "Version", "1.0" )
-                    && createKey( hkey, "VersionIndependentProgID", "so_activex.SOActiveX" )
+                ( ERROR_SUCCESS == RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey , NULL )
+                    && ERROR_SUCCESS == RegSetValueExA( hkey, "", 0, REG_SZ, (const BYTE*)"SOActiveX Class", 17 )
+                    && createKey( hkey, "Control", nKeyAccess )
+                    && createKey( hkey, "EnableFullPage", nKeyAccess )
+                    && createKey( hkey, "InprocServer32", nKeyAccess, pActiveXPath, "ThreadingModel", "Apartment" )
+                    && createKey( hkey, "MiscStatus", nKeyAccess, "0" )
+                    && createKey( hkey, "MiscStatus\\1", nKeyAccess, "131473" )
+                    && createKey( hkey, "ProgID", nKeyAccess, "so_activex.SOActiveX.1" )
+                    && createKey( hkey, "Programmable", nKeyAccess )
+                    && createKey( hkey, "ToolboxBitmap32", nKeyAccess, pActiveXPath101 )
+                    && createKey( hkey, "TypeLib", nKeyAccess, aTypeLib )
+                    && createKey( hkey, "Version", nKeyAccess, "1.0" )
+                    && createKey( hkey, "VersionIndependentProgID", nKeyAccess, "so_activex.SOActiveX" )
                 && ERROR_SUCCESS == RegCloseKey( hkey )
-                && ERROR_SUCCESS == RegCreateKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aPrefix, &hkey )
-                    && createKey( hkey, "so_activex.SOActiveX", "SOActiveX Class" )
-                    && ERROR_SUCCESS == RegCreateKey( hkey, "so_activex.SOActiveX", &hkey1 )
-                        && createKey( hkey1, "CLSID", aClassID )
-                        && createKey( hkey1, "CurVer", "so_activex.SOActiveX.1" )
+                && ERROR_SUCCESS == RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aPrefix, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey , NULL )
+                    && createKey( hkey, "so_activex.SOActiveX", nKeyAccess, "SOActiveX Class" )
+                    && ERROR_SUCCESS == RegCreateKeyExA( hkey, "so_activex.SOActiveX", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL )
+                        && createKey( hkey1, "CLSID", nKeyAccess, aClassID )
+                        && createKey( hkey1, "CurVer", nKeyAccess, "so_activex.SOActiveX.1" )
                     && ERROR_SUCCESS == RegCloseKey( hkey1 )
-                    && createKey( hkey, "so_activex.SOActiveX.1", "SOActiveX Class" )
-                    && ERROR_SUCCESS == RegCreateKey( hkey, "so_activex.SOActiveX.1", &hkey1 )
-                        && createKey( hkey1, "CLSID", aClassID )
+                    && createKey( hkey, "so_activex.SOActiveX.1", nKeyAccess, "SOActiveX Class" )
+                    && ERROR_SUCCESS == RegCreateKeyExA( hkey, "so_activex.SOActiveX.1", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL )
+                        && createKey( hkey1, "CLSID", nKeyAccess, aClassID )
                     && ERROR_SUCCESS == RegCloseKey( hkey1 )
-                    && ERROR_SUCCESS == RegCreateKey( hkey, "TypeLib", &hkey1 )
-                        && ERROR_SUCCESS == RegCreateKey( hkey1, aTypeLib, &hkey2 )
-                            && createKey( hkey2, "1.0", "wrap_activex 1.0 Type Library" )
-                            && ERROR_SUCCESS == RegCreateKey( hkey2, "1.0", &hkey3 )
-                                && ERROR_SUCCESS == RegCreateKey( hkey3, "0", &hkey4 )
-                                    && createKey( hkey4, "win32", pActiveXPath )
+                    && ERROR_SUCCESS == RegCreateKeyExA( hkey, "TypeLib", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL )
+                        && ERROR_SUCCESS == RegCreateKeyExA( hkey1, aTypeLib, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey2 , NULL )
+                            && createKey( hkey2, "1.0", nKeyAccess, "wrap_activex 1.0 Type Library" )
+                            && ERROR_SUCCESS == RegCreateKeyExA( hkey2, "1.0", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey3 , NULL )
+                                && ERROR_SUCCESS == RegCreateKeyExA( hkey3, "0", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey4 , NULL )
+                                    && createKey( hkey4, "win32", nKeyAccess, pActiveXPath )
                                 && ERROR_SUCCESS == RegCloseKey( hkey4 )
-                                && createKey( hkey3, "FLAGS", "0" )
-                                && createKey( hkey3, "HELPDIR", pPrCatalogPath )
+                                && createKey( hkey3, "FLAGS", nKeyAccess, "0" )
+                                && createKey( hkey3, "HELPDIR", nKeyAccess, pProgramPath )
                             && ERROR_SUCCESS == RegCloseKey( hkey3 )
                         && ERROR_SUCCESS == RegCloseKey( hkey2 )
                     && ERROR_SUCCESS == RegCloseKey( hkey1 )
-                    && ERROR_SUCCESS == RegCreateKey( hkey, "Interface", &hkey1 )
-                        && createKey( hkey1, aInterIDWinPeer, "ISOComWindowPeer" )
-                        && ERROR_SUCCESS == RegCreateKey( hkey1, aInterIDWinPeer, &hkey2 )
-                            && createKey( hkey2, "ProxyStubClsid", aProxyStubWinPeer )
-                            && createKey( hkey2, "ProxyStubClsid32", aProxyStubWinPeer )
-                            && createKey( hkey2, "TypeLib", aTypeLib, "Version", "1.0" )
+                    && ERROR_SUCCESS == RegCreateKeyExA( hkey, "Interface", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL )
+                        && createKey( hkey1, aInterIDWinPeer, nKeyAccess, "ISOComWindowPeer" )
+                        && ERROR_SUCCESS == RegCreateKeyExA( hkey1, aInterIDWinPeer, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey2 , NULL )
+                            && createKey( hkey2, "ProxyStubClsid", nKeyAccess, aProxyStubWinPeer )
+                            && createKey( hkey2, "ProxyStubClsid32", nKeyAccess, aProxyStubWinPeer )
+                            && createKey( hkey2, "TypeLib", nKeyAccess, aTypeLib, "Version", "1.0" )
                         && ERROR_SUCCESS == RegCloseKey( hkey2 )
-                        && createKey( hkey1, aInterIDActApprove, "ISOActionsApproval" )
-                        && ERROR_SUCCESS == RegCreateKey( hkey1, aInterIDActApprove, &hkey2 )
-                            && createKey( hkey2, "ProxyStubClsid", aProxyStubActApprove )
-                            && createKey( hkey2, "ProxyStubClsid32", aProxyStubActApprove )
-                            && createKey( hkey2, "TypeLib", aTypeLib, "Version", "1.0" )
+                        && createKey( hkey1, aInterIDActApprove, nKeyAccess, "ISOActionsApproval" )
+                        && ERROR_SUCCESS == RegCreateKeyExA( hkey1, aInterIDActApprove, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey2 , NULL )
+                            && createKey( hkey2, "ProxyStubClsid", nKeyAccess, aProxyStubActApprove )
+                            && createKey( hkey2, "ProxyStubClsid32", nKeyAccess, aProxyStubActApprove )
+                            && createKey( hkey2, "TypeLib", nKeyAccess, aTypeLib, "Version", "1.0" )
                         && ERROR_SUCCESS == RegCloseKey( hkey2 )
-                        && createKey( hkey1, aInterIDDispInt, "ISODispatchInterceptor" )
-                        && ERROR_SUCCESS == RegCreateKey( hkey1, aInterIDDispInt, &hkey2 )
-                            && createKey( hkey2, "ProxyStubClsid", aProxyStubDispInt )
-                            && createKey( hkey2, "ProxyStubClsid32", aProxyStubDispInt )
-                            && createKey( hkey2, "TypeLib", aTypeLib, "Version", "1.0" )
+                        && createKey( hkey1, aInterIDDispInt, nKeyAccess, "ISODispatchInterceptor" )
+                        && ERROR_SUCCESS == RegCreateKeyExA( hkey1, aInterIDDispInt, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey2 , NULL )
+                            && createKey( hkey2, "ProxyStubClsid", nKeyAccess, aProxyStubDispInt )
+                            && createKey( hkey2, "ProxyStubClsid32", nKeyAccess, aProxyStubDispInt )
+                            && createKey( hkey2, "TypeLib", nKeyAccess, aTypeLib, "Version", "1.0" )
                         && ERROR_SUCCESS == RegCloseKey( hkey2 )
                     && ERROR_SUCCESS == RegCloseKey( hkey1 )
                 && ERROR_SUCCESS == RegCloseKey( hkey ) );
@@ -259,11 +281,11 @@ STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, const char* pActiv
     {
         if( nForModes[ind] & nMode )
         {
-            wsprintf( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMimeType[ind] );
-            if ( ERROR_SUCCESS != RegCreateKey(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey)
-//          	|| ERROR_SUCCESS != RegSetValueEx(hkey, "Extension", 0, REG_SZ, 
-//	             (const BYTE *)aFileExt[ind], strlen( aFileExt[ind] ) )
-              || ERROR_SUCCESS != RegSetValueEx(hkey, "CLSID", 0, REG_SZ,
+            wsprintfA( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMimeType[ind] );
+            if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL )
+//              || ERROR_SUCCESS != RegSetValueExA(hkey, "Extension", 0, REG_SZ, 
+//                 (const BYTE *)aFileExt[ind], strlen( aFileExt[ind] ) )
+              || ERROR_SUCCESS != RegSetValueExA(hkey, "CLSID", 0, REG_SZ,
                  (const BYTE *)aClassID, strlen(aClassID)) )
                     aResult = FALSE;
     
@@ -271,9 +293,9 @@ STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, const char* pActiv
                 RegCloseKey(hkey),hkey= NULL;
 
 /*
-            wsprintf( aSubKey, "%s%s", aPrefix, aFileExt[ind] );
-            if ( ERROR_SUCCESS != RegCreateKey(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey) 
-              || ERROR_SUCCESS != RegSetValueEx(hkey, "Content Type", 0, REG_SZ,
+            wsprintfA( aSubKey, "%s%s", aPrefix, aFileExt[ind] );
+            if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) 
+              || ERROR_SUCCESS != RegSetValueExA(hkey, "Content Type", 0, REG_SZ,
                  (const BYTE *)aMimeType[ind], strlen( aMimeType[ind] ) ) )
                     aResult = FALSE;
             if( hkey )    
@@ -282,13 +304,13 @@ STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, const char* pActiv
         }
     }
 
-    wsprintf( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
-    if ( aResult && ERROR_SUCCESS == RegOpenKey(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey) )
+    wsprintfA( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+    if ( aResult && ERROR_SUCCESS == RegOpenKeyExA(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, nKeyAccess, &hkey) )
     {
            for( ind = 0; ind < SUPPORTED_EXT_NUM; ind++ )
            {
-               wsprintf( aSubKey, "EnableFullPage\\%s", aFileExt[ind] );
-               if ( ERROR_SUCCESS != RegCreateKey( hkey, aSubKey, &hkey1 ) )
+               wsprintfA( aSubKey, "EnableFullPage\\%s", aFileExt[ind] );
+               if ( ERROR_SUCCESS != RegCreateKeyExA( hkey, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL ) )
                    aResult = FALSE;
     
             if ( hkey1 )
@@ -304,30 +326,62 @@ STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, const char* pActiv
     return aResult;
 }
 
+STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, BOOL bFor64Bit, const char* pProgramPath )
+{
+    HRESULT hr = S_OK;
+    if ( bFor64Bit )
+        hr = DllRegisterServerNative_Impl( nMode, bForAllUsers, n64KeyAccess, pProgramPath, X64_LIB_NAME );
+
+    if ( SUCCEEDED( hr ) )
+        hr = DllRegisterServerNative_Impl( nMode, bForAllUsers, n32KeyAccess, pProgramPath, X32_LIB_NAME );
+
+    return hr;
+}
+
+
 /////////////////////////////////////////////////////////////////////////////
 // DllUnregisterServer - Removes entries from the system registry
+HRESULT DeleteKeyTree( HKEY hkey, const char* pPath, REGSAM nKeyAccess )
+{
+    HKEY hkey1 = NULL;
+
+    char pSubKeyName[256];
+    // first delete the subkeys
+    while( ERROR_SUCCESS == RegOpenKeyExA( hkey, pPath, 0, nKeyAccess, &hkey1)
+        && ERROR_SUCCESS == RegEnumKeyA( hkey1, 0, pSubKeyName, 256 )
+        && ERROR_SUCCESS == DeleteKeyTree( hkey1, pSubKeyName, nKeyAccess ) )
+    {
+        RegCloseKey( hkey1 ),hkey1= NULL;
+    }
+
+    if ( hkey1 )
+        RegCloseKey( hkey1 ),hkey1= NULL;
+
+    // delete the key itself
+    return RegDeleteKeyExA( hkey, pPath, nKeyAccess & ( KEY_WOW64_64KEY | KEY_WOW64_32KEY ), 0 );
+}
 
-STDAPI DllUnregisterServerNative( int nMode, BOOL bForAllUsers )
+STDAPI DllUnregisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess )
 {
     HKEY        hkey = NULL;
     BOOL        fErr = FALSE;
-    char        aSubKey[513];
-    const char*	aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
+    char aSubKey[513];
+    const char*    aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
     
-      for( int ind = 0; ind < SUPPORTED_EXT_NUM; ind++ )
+    for( int ind = 0; ind < SUPPORTED_EXT_NUM; ind++ )
     {
         if( nForModes[ind] & nMode )
         {
             DWORD nSubKeys = 0, nValues = 0;
-               wsprintf( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMimeType[ind] );
-               if ( ERROR_SUCCESS != RegCreateKey(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey) )
+            wsprintfA( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMimeType[ind] );
+            if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) )
                 fErr = TRUE;
             else
             {
-                   if ( ERROR_SUCCESS != RegDeleteValue( hkey, "CLSID" ) )
+                if ( ERROR_SUCCESS != RegDeleteValue( hkey, "CLSID" ) )
                     fErr = TRUE;
     
-                   if ( ERROR_SUCCESS != RegQueryInfoKey(  hkey, NULL, NULL, NULL,
+                if ( ERROR_SUCCESS != RegQueryInfoKey(  hkey, NULL, NULL, NULL,
                                                     &nSubKeys, NULL, NULL,
                                                     &nValues, NULL, NULL, NULL, NULL ) )
                 {
@@ -338,12 +392,12 @@ STDAPI DllUnregisterServerNative( int nMode, BOOL bForAllUsers )
                 {
                     RegCloseKey( hkey ), hkey = NULL;
                     if ( !nSubKeys && !nValues )
-                        SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey );
+                        DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess );
                 }
             }
     
-               wsprintf( aSubKey, "%s%s", aPrefix, aFileExt[ind] );
-               if ( ERROR_SUCCESS != RegCreateKey(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey) )
+               wsprintfA( aSubKey, "%s%s", aPrefix, aFileExt[ind] );
+               if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) )
                 fErr = TRUE;
             else
             {
@@ -358,43 +412,53 @@ STDAPI DllUnregisterServerNative( int nMode, BOOL bForAllUsers )
                 {
                     RegCloseKey( hkey ), hkey = NULL;
                     if ( !nSubKeys && !nValues )
-                        SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey );
+                        DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess );
                 }
             }
         }
     }
 
-    wsprintf( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
-    if( ERROR_SUCCESS != SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey ) )
+    wsprintfA( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+    if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
            fErr = TRUE;
 
-    wsprintf( aSubKey, "%sso_activex.SOActiveX", aPrefix );
-    if( ERROR_SUCCESS != SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey ) )
+    wsprintfA( aSubKey, "%sso_activex.SOActiveX", aPrefix );
+    if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
            fErr = TRUE;
 
-    wsprintf( aSubKey, "%sso_activex.SOActiveX.1", aPrefix );
-    if( ERROR_SUCCESS != SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey ) )
+    wsprintfA( aSubKey, "%sso_activex.SOActiveX.1", aPrefix );
+    if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
            fErr = TRUE;
 
-    wsprintf( aSubKey, "%s\\TypeLib\\%s", aPrefix, aTypeLib );
-    if( ERROR_SUCCESS != SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey ) )
+    wsprintfA( aSubKey, "%s\\TypeLib\\%s", aPrefix, aTypeLib );
+    if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
            fErr = TRUE;
 
-    wsprintf( aSubKey, "%s\\Interface\\%s", aPrefix, aInterIDWinPeer );
-    if( ERROR_SUCCESS != SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey ) )
+    wsprintfA( aSubKey, "%s\\Interface\\%s", aPrefix, aInterIDWinPeer );
+    if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
            fErr = TRUE;
 
-    wsprintf( aSubKey, "%s\\Interface\\%s", aPrefix, aInterIDDispInt );
-    if( ERROR_SUCCESS != SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey ) )
+    wsprintfA( aSubKey, "%s\\Interface\\%s", aPrefix, aInterIDDispInt );
+    if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
            fErr = TRUE;
 
-    wsprintf( aSubKey, "%s\\Interface\\%s", aPrefix, aInterIDActApprove );
-    if( ERROR_SUCCESS != SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey ) )
+    wsprintfA( aSubKey, "%s\\Interface\\%s", aPrefix, aInterIDActApprove );
+    if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
            fErr = TRUE;
 
     return !fErr;
 }
 
+STDAPI DllUnregisterServerNative( int nMode, BOOL bForAllUsers, BOOL bFor64Bit )
+{
+    HRESULT hr = DllUnregisterServerNative_Impl( nMode, bForAllUsers, n32KeyAccess );
+    if ( SUCCEEDED( hr ) && bFor64Bit )
+        hr = DllUnregisterServerNative_Impl( nMode, bForAllUsers, n64KeyAccess );
+
+    return hr;
+}
+
+
 /////////////////////////////////////////////////////////////////////////////
 // DllRegisterServerDoc - Adds entries to the system registry
 
@@ -409,41 +473,41 @@ const char* aMSMimeType[] = { "application/msword",
                           "application/mspowerpoint" };
 const int nForMSModes[] = { 1, 1, 2, 2, 4, 4, 4 };
 
-STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers );
-STDAPI DllRegisterServerDoc( int nMode, BOOL bForAllUsers )
+STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers, BOOL bFor64Bit );
+STDAPI DllRegisterServerDoc_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess )
 {
     BOOL aResult = TRUE;
 
     HKEY        hkey = NULL;
     HKEY        hkey1 = NULL;
-    char        aSubKey[513];
+    char aSubKey[513];
     int         ind;
-    const char*	aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
+    const char*    aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
 
     // In case SO7 is installed for this user he can have local registry entries that will prevent him from
     // using SO8 ActiveX control. The fix is just to clean up the local entries related to ActiveX control.
     // Unfortunately it can be done only for the user who installs the office.
     if ( bForAllUsers )
-        DllUnregisterServerDoc( nMode, sal_False );
+        DllUnregisterServerDoc( nMode, sal_False, sal_False );
 
     for( ind = 0; ind < SUPPORTED_MSEXT_NUM && aResult; ind++ )
     {
         if( nForMSModes[ind] & nMode )
         {
-               wsprintf( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMSMimeType[ind] );
-               if ( ERROR_SUCCESS != RegCreateKey(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey)
-               || ERROR_SUCCESS != RegSetValueEx(hkey, "Extension", 0, REG_SZ, 
+               wsprintfA( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMSMimeType[ind] );
+               if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL )
+               || ERROR_SUCCESS != RegSetValueExA(hkey, "Extension", 0, REG_SZ, 
                    (const BYTE *)aMSFileExt[ind], strlen( aMSFileExt[ind] ) )
-               || ERROR_SUCCESS != RegSetValueEx(hkey, "CLSID", 0, REG_SZ,
+               || ERROR_SUCCESS != RegSetValueExA(hkey, "CLSID", 0, REG_SZ,
                    (const BYTE *)aClassID, strlen(aClassID)) )
                        aResult = FALSE;
     
                if( hkey )    
                    RegCloseKey(hkey),hkey= NULL;
     
-               wsprintf( aSubKey, "%s%s", aPrefix, aMSFileExt[ind] );
-               if ( ERROR_SUCCESS != RegCreateKey(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey) 
-               || ERROR_SUCCESS != RegSetValueEx(hkey, "Content Type", 0, REG_SZ,
+               wsprintfA( aSubKey, "%s%s", aPrefix, aMSFileExt[ind] );
+               if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) 
+               || ERROR_SUCCESS != RegSetValueExA(hkey, "Content Type", 0, REG_SZ,
                    (const BYTE *)aMSMimeType[ind], strlen( aMSMimeType[ind] ) ) )
                        aResult = FALSE;
     
@@ -452,16 +516,16 @@ STDAPI DllRegisterServerDoc( int nMode, BOOL bForAllUsers )
         }
     }
 
-    wsprintf( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
-    if ( aResult && ERROR_SUCCESS == RegCreateKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey )
-      && createKey( hkey, "EnableFullPage" ) )
+    wsprintfA( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+    if ( aResult && ERROR_SUCCESS == RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey , NULL )
+      && createKey( hkey, "EnableFullPage", nKeyAccess ) )
     {
            for( ind = 0; ind < SUPPORTED_MSEXT_NUM; ind++ )
            {
             if( nForMSModes[ind] & nMode )
             {
-                   wsprintf( aSubKey, "EnableFullPage\\%s", aMSFileExt[ind] );
-                   if ( ERROR_SUCCESS != RegCreateKey( hkey, aSubKey, &hkey1 ) )
+                   wsprintfA( aSubKey, "EnableFullPage\\%s", aMSFileExt[ind] );
+                   if ( ERROR_SUCCESS != RegCreateKeyExA( hkey, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL ) )
                        aResult = FALSE;
 
                    if ( hkey1 )
@@ -478,17 +542,28 @@ STDAPI DllRegisterServerDoc( int nMode, BOOL bForAllUsers )
     return aResult;
 }
 
+STDAPI DllRegisterServerDoc( int nMode, BOOL bForAllUsers, BOOL bFor64Bit )
+{
+    HRESULT hr = S_OK;
+    if ( bFor64Bit )
+        hr = DllRegisterServerDoc_Impl( nMode, bForAllUsers, n64KeyAccess );
+
+    if ( SUCCEEDED( hr ) )
+        hr = DllRegisterServerDoc_Impl( nMode, bForAllUsers, n32KeyAccess );
+
+    return hr;
+}
 
 
 /////////////////////////////////////////////////////////////////////////////
 // DllUnregisterServerDoc - Removes entries from the system registry
 
-STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers )
+STDAPI DllUnregisterServerDoc_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess )
 {
     HKEY        hkey = NULL;
     BOOL        fErr = FALSE;
-    char        aSubKey[513];
-    const char*	aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
+    char aSubKey[513];
+    const char*    aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
     
       for( int ind = 0; ind < SUPPORTED_MSEXT_NUM; ind++ )
        {
@@ -496,8 +571,8 @@ STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers )
         {
             DWORD nSubKeys = 0, nValues = 0;
         
-               wsprintf( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMSMimeType[ind] );
-               if ( ERROR_SUCCESS != RegCreateKey(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey) )
+               wsprintfA( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMSMimeType[ind] );
+               if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) )
                 fErr = TRUE;
             else
             {
@@ -518,12 +593,12 @@ STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers )
                 {
                     RegCloseKey( hkey ), hkey = NULL;
                     if ( !nSubKeys && !nValues )
-                        SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey );
+                        DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess );
                 }
             }
 
-               wsprintf( aSubKey, "%s%s", aPrefix, aMSFileExt[ind] );
-               if ( ERROR_SUCCESS != RegCreateKey(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, &hkey) )
+               wsprintfA( aSubKey, "%s%s", aPrefix, aMSFileExt[ind] );
+               if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) )
                 fErr = TRUE;
             else
             {
@@ -541,7 +616,7 @@ STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers )
                 {
                     RegCloseKey( hkey ), hkey = NULL;
                     if ( !nSubKeys && !nValues )
-                        SHDeleteKey( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey );
+                        DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess );
                 }
             }
         }
@@ -550,33 +625,59 @@ STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers )
     return !fErr;
 }
 
+STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers, BOOL bFor64Bit )
+{
+    HRESULT hr = S_OK;
+    if ( bFor64Bit )
+        hr = DllUnregisterServerDoc_Impl( nMode, bForAllUsers, n64KeyAccess );
+
+    if ( SUCCEEDED( hr ) )
+        hr = DllUnregisterServerDoc_Impl( nMode, bForAllUsers, n32KeyAccess );
+
+    return hr;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - regsvr32 entry point
+
 STDAPI DllRegisterServer( void )
 {
-    char pActiveXPath[1019];
+    char pProgramPath[1024];
     HRESULT aResult = E_FAIL;
 
-    HMODULE aCurModule = GetModuleHandleA( "so_activex.dll" );
-    if( aCurModule && GetModuleFileNameA( aCurModule, pActiveXPath, 1019 ) )
+    HMODULE aCurModule = GetModuleHandleA( bX64 ? X64_LIB_NAME : X32_LIB_NAME );
+    DWORD nLen = 0;
+    DWORD nLibNameLen = strlen( bX64 ? X64_LIB_NAME : X32_LIB_NAME );
+
+    if( aCurModule )
     {
-        aResult = DllRegisterServerNative( 31, TRUE, pActiveXPath );
-        if( SUCCEEDED( aResult ) )
-            aResult = DllRegisterServerDoc( 31, TRUE );
-        else
+        nLen = GetModuleFileNameA( aCurModule, pProgramPath, 1024 );
+        if ( nLen && nLen > nLibNameLen + 1 )
         {
-            aResult = DllRegisterServerNative( 31, FALSE, pActiveXPath );
+            pProgramPath[ nLen - nLibNameLen - 1 ] = 0;
+            aResult = DllRegisterServerNative( 31, TRUE, bX64, pProgramPath );
             if( SUCCEEDED( aResult ) )
-                aResult = DllRegisterServerDoc( 31, FALSE );
+                aResult = DllRegisterServerDoc( 31, TRUE, bX64 );
+            else
+            {
+                aResult = DllRegisterServerNative( 31, FALSE, bX64, pProgramPath );
+                if( SUCCEEDED( aResult ) )
+                    aResult = DllRegisterServerDoc( 31, FALSE, bX64 );
+            }
         }
     }
 
     return aResult;
 }
 
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - regsvr32 entry point
+
 STDAPI DllUnregisterServer( void )
 {
-    DllUnregisterServerDoc( 63, FALSE );
-    DllUnregisterServerNative( 63, FALSE );
-    DllUnregisterServerDoc( 63, TRUE );
-    return DllUnregisterServerNative( 63, TRUE );
+    DllUnregisterServerDoc( 63, FALSE, bX64 );
+    DllUnregisterServerNative( 63, FALSE, bX64 );
+    DllUnregisterServerDoc( 63, TRUE, bX64 );
+    return DllUnregisterServerNative( 63, TRUE, bX64 );
 }
 
diff --git a/setup_native/prj/build.lst b/setup_native/prj/build.lst
index 8835ff0..e5aca56 100644
--- a/setup_native/prj/build.lst
+++ b/setup_native/prj/build.lst
@@ -9,6 +9,7 @@ pk  setup_native\source\win32\customactions\rebase        nmake   -  w   sn_reba
 pk  setup_native\source\win32\customactions\regactivex    nmake   -  w   sn_regactivex NULL
 pk  setup_native\source\win32\customactions\regpatchactivex nmake -  w   sn_regpatchactivex NULL
 pk  setup_native\source\win32\customactions\reg4allmsdoc  nmake   -  w   sn_reg4allmsdoc NULL
+pk  setup_native\source\win32\customactions\reg64		  nmake   -  w   sn_reg64 NULL
 pk  setup_native\source\win32\customactions\javafilter    nmake   -  w   sn_javafilter NULL
 pk  setup_native\source\win32\customactions\quickstarter  nmake   -  w   sn_quickstarter NULL
 pk  setup_native\source\win32\customactions\shellextensions nmake   -  w   sn_shellextensions sn_tools.w NULL
diff --git a/setup_native/source/win32/customactions/reg64/exports.dxp b/setup_native/source/win32/customactions/reg64/exports.dxp
new file mode 100755
index 0000000..3282da1
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg64/exports.dxp
@@ -0,0 +1,2 @@
+InstallReg64
+DeinstallReg64
diff --git a/setup_native/source/win32/customactions/reg64/makefile.mk b/setup_native/source/win32/customactions/reg64/makefile.mk
new file mode 100755
index 0000000..17c5671
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg64/makefile.mk
@@ -0,0 +1,112 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.20 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org.  If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=setup_native
+TARGET=reg64msi
+
+# --- Settings -----------------------------------------------------
+
+ENABLE_EXCEPTIONS=TRUE
+NO_DEFAULT_STL=TRUE
+DYNAMIC_CRT=
+USE_DEFFILE=TRUE
+EXTERNAL_WARNINGS_NOT_ERRORS := TRUE 
+
+.INCLUDE : settings.mk
+
+.IF "$(USE_SYSTEM_STL)" != "YES"
+CFLAGS+=-D_STLP_USE_STATIC_LIB
+.ENDIF
+
+#Disable precompiled header
+CDEFS+=-Dnot_used_define_to_disable_pch
+
+# --- Files --------------------------------------------------------
+
+.IF "$(GUI)"=="WNT"
+
+UWINAPILIB=
+
+SLOFILES = \
+    $(SLO)$/reg64.obj
+
+STDSHL += \
+    $(KERNEL32LIB)\
+    $(USER32LIB)\
+    $(ADVAPI32LIB)\
+    $(SHELL32LIB)\
+    $(MSILIB)\
+    $(SHLWAPILIB)\
+    
+#	msvcprt.lib 							
+
+SHL1TARGET = $(TARGET)
+SHL1IMPLIB = i$(TARGET)
+
+SHL1OBJS=$(SLOFILES) 
+SHL1DEF = $(MISC)$/$(SHL1TARGET).def
+SHL1DEPN = $(SLB)$/$(TARGET).lib
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+.ENDIF
+
+
+# --- mapimailer --------------------------------------------------------
+
+#TARGETTYPE=CUI
+
+#OBJFILES=   $(OBJ)$/reg64.obj
+
+#APP1TARGET=reg64
+#APP1OBJS=$(OBJFILES)
+#APP1STDLIBS=$(KERNEL32LIB)\
+#	$(ADVAPI32LIB)\
+#	$(MSILIB)\
+#   $(SHELL32LIB)\
+#    msvcprt.lib\
+#    $(OLE32LIB)\
+#    $(COMCTL32LIB)\
+#    $(UUIDLIB)
+
+            
+#APP1DEF=$(MISC)$/$(APP1TARGET).def 
+
+# --- Targets --------------------------------------------------------------
+
+.INCLUDE : target.mk
+INCLUDE!:=$(subst,/stl, $(INCLUDE))
+.EXPORT : INCLUDE
+
+# -------------------------------------------------------------------------
+
+
diff --git a/setup_native/source/win32/customactions/reg64/reg64.cxx b/setup_native/source/win32/customactions/reg64/reg64.cxx
new file mode 100755
index 0000000..c2e316b
--- /dev/null
+++ b/setup_native/source/win32/customactions/reg64/reg64.cxx
@@ -0,0 +1,474 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+* 
+* Copyright 2008 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* $RCSfile: shellextensions.cxx,v $
+* $Revision: 1.7 $
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org.  If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+************************************************************************/
+
+/*
+
+*/
+
+
+#define UNICODE
+
+#ifdef _MSC_VER
+#pragma warning(push, 1) /* disable warnings within system headers */
+#endif
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <msiquery.h>
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+#include <malloc.h>
+//#include <string>
+//#include <map> 
+#include <strsafe.h>
+
+// 10.11.2009 tkr: MinGW doesn't know anything about RegDeleteKeyExW if WINVER < 0x0502.
+WINADVAPI LONG WINAPI RegDeleteKeyExW(HKEY,LPCWSTR,REGSAM,DWORD); 
+
+// 06.11.2009 tkr: to provide windows xp as build systems for mingw we need to define KEY_WOW64_64KEY
+// in mingw 3.13 KEY_WOW64_64KEY isn't available < Win2003 systems. 
+// Also defined in setup_native\source\win32\customactions\reg64\reg64.cxx,source\win32\customactions\shellextensions\shellextensions.cxx and
+// extensions\source\activex\main\so_activex.cpp
+#ifndef KEY_WOW64_64KEY
+    #define KEY_WOW64_64KEY	(0x0100)
+#endif
+
+
+#define TABLE_NAME L"Reg64"
+#define BASISINSTALLLOCATION L"[BASISINSTALLLOCATION]"
+
+bool isInstall4AllUsers;
+wchar_t * sBasisInstallLocation;
+
+
+enum OPERATION {
+    SET,
+    REMOVE
+};
+
+#ifdef DEBUG
+inline void OutputDebugStringFormat( const wchar_t* pFormat, ... )
+{
+    wchar_t    buffer[1024];
+    va_list args;
+
+    va_start( args, pFormat );
+    StringCchVPrintf( buffer, sizeof(buffer), pFormat, args );
+    OutputDebugString( buffer );
+}
+#else
+static inline void OutputDebugStringFormat( const wchar_t*, ... )
+{
+}
+#endif
+
+bool WriteRegistry( MSIHANDLE & hMSI, OPERATION op, const wchar_t* componentName)
+{
+    INSTALLSTATE current_state;
+    INSTALLSTATE comp_state; 
+    UINT ret = MsiGetComponentState( hMSI, componentName, &current_state, &comp_state );
+    if ( ERROR_SUCCESS == ret )
+    {
+        if (current_state == INSTALLSTATE_ABSENT)
+            OutputDebugStringFormat(L"WriteRegistry - current_state: INSTALLSTATE_ABSENT");
+        else if (current_state == INSTALLSTATE_DEFAULT)
+            OutputDebugStringFormat(L"WriteRegistry - current_state: INSTALLSTATE_DEFAULT");
+        else if (current_state == INSTALLSTATE_LOCAL)
+            OutputDebugStringFormat(L"WriteRegistry - current_state: INSTALLSTATE_LOCAL");
+        else if (current_state == INSTALLSTATE_REMOVED)
+            OutputDebugStringFormat(L"WriteRegistry - current_state: INSTALLSTATE_REMOVED");
+        else if (current_state == INSTALLSTATE_SOURCE)
+            OutputDebugStringFormat(L"WriteRegistry - current_state: INSTALLSTATE_SOURCE");
+        else if (current_state == INSTALLSTATE_UNKNOWN)
+            OutputDebugStringFormat(L"WriteRegistry - current_state: INSTALLSTATE_UNKNOWN");
+
+        if (comp_state == INSTALLSTATE_ABSENT)
+            OutputDebugStringFormat(L"WriteRegistry - comp_state: INSTALLSTATE_ABSENT");
+        else if (comp_state == INSTALLSTATE_DEFAULT)
+            OutputDebugStringFormat(L"WriteRegistry - comp_state: INSTALLSTATE_DEFAULT");
+        else if (comp_state == INSTALLSTATE_LOCAL)
+            OutputDebugStringFormat(L"WriteRegistry - comp_state: INSTALLSTATE_LOCAL");
+        else if (comp_state == INSTALLSTATE_REMOVED)
+            OutputDebugStringFormat(L"WriteRegistry - comp_state: INSTALLSTATE_REMOVED");
+        else if (comp_state == INSTALLSTATE_SOURCE)
+            OutputDebugStringFormat(L"WriteRegistry - comp_state: INSTALLSTATE_SOURCE");
+        else if (comp_state == INSTALLSTATE_UNKNOWN)
+            OutputDebugStringFormat(L"WriteRegistry - comp_state: INSTALLSTATE_UNKNOWN");
+
+        switch (op)
+        {
+            case SET :
+                if ( comp_state == INSTALLSTATE_LOCAL || ( current_state == INSTALLSTATE_LOCAL && comp_state == INSTALLSTATE_UNKNOWN ) )
+                {
+                    return true;
+                }
+                break;
+            case REMOVE:
+                OutputDebugStringFormat(L"WriteRegistry - Remove\n" );
+                if ( current_state == INSTALLSTATE_LOCAL && (comp_state == INSTALLSTATE_ABSENT || comp_state == INSTALLSTATE_REMOVED) )
+                {
+                    OutputDebugStringFormat(L"WriteRegistry - To be removed\n" );
+                    return true;
+                }
+        }
+    } else
+    {
+        if (ERROR_INVALID_HANDLE == ret) OutputDebugStringFormat(L"WriteRegistry - Invalid handle");
+        if (ERROR_UNKNOWN_FEATURE  == ret) OutputDebugStringFormat(L"WriteRegistry - Unknown feature");
+    }
+
+    return false;
+}
+
+BOOL UnicodeEquals( wchar_t* pStr1, wchar_t* pStr2 )
+{
+    if ( pStr1 == NULL && pStr2 == NULL )
+        return TRUE;
+    else if ( pStr1 == NULL || pStr2 == NULL )
+        return FALSE;
+
+    while( *pStr1 == *pStr2 && *pStr1 && *pStr2 )
+        pStr1++, pStr2++;
+
+    return ( *pStr1 == 0 && *pStr2 == 0 );
+} 
+
+BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
+{
+    OutputDebugStringFormat(L"GetMsiProp - START\n" );
+    DWORD sz = 0;
+    UINT ret = MsiGetProperty( hMSI, pPropName, L"", &sz );
+       if ( ret == ERROR_MORE_DATA )
+       {
+           sz++;
+           DWORD nbytes = sz * sizeof( wchar_t );
+           wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) );
+           ZeroMemory( buff, nbytes );
+           MsiGetProperty( hMSI, pPropName, buff, &sz );
+
+        OutputDebugStringFormat(L"GetMsiProp - Value" );
+        OutputDebugStringFormat( buff );
+           *ppValue = buff;
+
+        return TRUE;
+    } else if (ret  == ERROR_INVALID_HANDLE)
+    {	
+        OutputDebugStringFormat(L"GetMsiProp - ERROR_INVALID_HANDLE" );
+    } else if (ret == ERROR_INVALID_PARAMETER)
+    {
+        OutputDebugStringFormat(L"GetMsiProp - ERROR_INVALID_PARAMETER" );		
+    } else if (ret == ERROR_SUCCESS)
+    {
+        OutputDebugStringFormat(L"GetMsiProp - ERROR_SUCCESS" );
+    }
+
+
+    OutputDebugStringFormat(L"GetMsiProp - ENDE\n" );
+    return FALSE;
+} 
+
+bool IsInstallForAllUsers( MSIHANDLE hMSI )
+{
+    OutputDebugStringFormat(L"IsInstallForAllUsers - START\n" );
+    bool bResult = FALSE;
+    wchar_t* pVal = NULL;
+    if ( GetMsiProp( hMSI, L"ALLUSERS", &pVal ) && pVal )
+    {
+        bResult = UnicodeEquals( pVal , L"1" );
+        free( pVal );
+    }
+
+    OutputDebugStringFormat(L"IsInstallForAllUsers - ENDE\n" );
+    return bResult;
+}
+
+wchar_t* GetBasisInstallLocation( MSIHANDLE hMSI )
+{
+    OutputDebugStringFormat(L"GetBasisInstallLocation - START\n" );
+    bool bResult = FALSE;
+    wchar_t* pVal = NULL;
+    GetMsiProp( hMSI, L"BASISINSTALLLOCATION", &pVal);
+
+    OutputDebugStringFormat(L"GetBasisInstallLocation - ENDE\n" );
+    return pVal;
+}
+ 
+
+bool QueryReg64Table(MSIHANDLE& rhDatabase, MSIHANDLE& rhView) 
+{
+    OutputDebugStringFormat(L"QueryReg64Table - START\n" );
+    int const arraysize = 400;
+    wchar_t szSelect[arraysize];
+    StringCbPrintfW(szSelect, arraysize * sizeof(wchar_t), L"SELECT * FROM %s",TABLE_NAME);
+    OutputDebugStringFormat( szSelect );
+
+    UINT ret = MsiDatabaseOpenView(rhDatabase,szSelect,&rhView);
+    if (ret != ERROR_SUCCESS)
+    {
+        if ( ret == ERROR_BAD_QUERY_SYNTAX)
+            OutputDebugStringFormat(L"QueryReg64Table - MsiDatabaseOpenView - FAILED - ERROR_BAD_QUERY_SYNTAX\n" );
+        if ( ret == ERROR_INVALID_HANDLE)
+            OutputDebugStringFormat(L"QueryReg64Table - MsiDatabaseOpenView - FAILED - ERROR_INVALID_HANDLE\n" );
+        return false;
+    }
+    // execute query - not a parameter query so second parameter is NULL.
+    if (MsiViewExecute(rhView,NULL) != ERROR_SUCCESS)
+    {
+        OutputDebugStringFormat(L"QueryReg64Table - MsiViewExecute - FAILED\n" );
+        return false;
+    }
+
+    OutputDebugStringFormat(L"QueryReg64Table - ENDE\n" );
+    return true;
+}
+
+//---------------------------------------
+bool DeleteRegistryKey(HKEY RootKey, const wchar_t* KeyName)
+{
+    int rc = RegDeleteKeyExW(
+        RootKey, KeyName, KEY_WOW64_64KEY, 0);
+
+    return (ERROR_SUCCESS == rc);
+}
+
+
+
+
+//---------------------------------------
+//
+//---------------------------------------
+
+bool SetRegistryKey(HKEY RootKey, const wchar_t* KeyName, const wchar_t* ValueName, const wchar_t* Value)
+{
+    HKEY hSubKey;
+
+    // open or create the desired key
+    int rc = RegCreateKeyEx(
+        RootKey, KeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_WOW64_64KEY, 0, &hSubKey, 0);
+
+    if (ERROR_SUCCESS == rc)
+    {
+        OutputDebugStringFormat(L"SetRegistryKey - Created\n" );
+        rc = RegSetValueEx(
+            hSubKey, ValueName, 0, REG_SZ, reinterpret_cast<const BYTE*>(Value), (wcslen(Value) + 1) * sizeof(wchar_t));
+
+        RegCloseKey(hSubKey);
+    } else {
+        OutputDebugStringFormat(L"SetRegistryKey - FAILED\n" );
+    }
+
+
+    return (ERROR_SUCCESS == rc);
+}
+
+bool DoRegEntries( MSIHANDLE& rhMSI, OPERATION op, MSIHANDLE& rhView)
+{
+    OutputDebugStringFormat(L"DoRegEntries - START\n" );
+    
+    MSIHANDLE hRecord;
+    
+    long lRoot;
+    wchar_t  szKey[255];
+    wchar_t  szName[255];
+    wchar_t  szValue[1024];
+    wchar_t  szComponent[255];
+
+    /// read records until there are no more records
+    while (MsiViewFetch(rhView,&hRecord) == ERROR_SUCCESS)
+    {
+        DWORD	 dwKey = 255;
+        DWORD	 dwName = 255;
+        DWORD	 dwValue = 1024;
+        DWORD	 dwComponent = 255;
+        
+        szKey[0] = '\0';
+        szName[0] = '\0';
+        szValue[0] = '\0';
+        szComponent[0] = '\0';
+        
+        lRoot = MsiRecordGetInteger(hRecord,2);
+        MsiRecordGetString(hRecord,3,szKey,&dwKey);
+        
+        if (!MsiRecordIsNull(hRecord, 4)) 
+            MsiRecordGetString(hRecord,4,szName,&dwName);
+        
+        if (!MsiRecordIsNull(hRecord, 5))
+        {
+            MsiRecordGetString(hRecord,5,szValue,&dwValue);			
+                
+            
+    
+            wchar_t* nPos = wcsstr(szValue , BASISINSTALLLOCATION);
+            if ( NULL != nPos)
+            {
+
+                DWORD nPrefixSize = nPos - szValue;
+
+                DWORD nPropSize = wcslen(sBasisInstallLocation);
+                DWORD nPostfixSize = dwValue - wcslen( BASISINSTALLLOCATION );
+
+                DWORD nNewValueBytes = (nPropSize + nPostfixSize + 1) * sizeof( wchar_t );
+                   wchar_t* newValue = reinterpret_cast<wchar_t*>( malloc( nNewValueBytes ) );
+                   ZeroMemory( newValue, nNewValueBytes );
+
+                // prefix
+                wcsncpy(newValue, szValue, nPrefixSize);
+                
+                // basis location
+                wcsncat(newValue, sBasisInstallLocation, nPropSize * sizeof( wchar_t ));
+
+                // postfix
+                wcsncat(newValue, nPos + ( wcslen( BASISINSTALLLOCATION ) ), nPropSize * sizeof( wchar_t ));
+                
+                wcsncpy(szValue, newValue, nNewValueBytes <=1024? nNewValueBytes: 1024);
+
+                free(newValue);
+            }
+            
+        }
+        
+    
+        MsiRecordGetString(hRecord,6,szComponent,&dwComponent);
+
+        OutputDebugStringFormat(L"****** DoRegEntries *******" );
+        OutputDebugStringFormat(L"Root:" );
+        HKEY key = HKEY_CURRENT_USER;
+        switch (lRoot)
+        {
+            case(-1):
+                    if (isInstall4AllUsers)
+                    {
+                        key = HKEY_CURRENT_USER;
+                        OutputDebugStringFormat(L"HKEY_CURRENT_USER" );
+                    }
+                    else
+                    {
+                        key = HKEY_LOCAL_MACHINE;
+                        OutputDebugStringFormat(L"HKEY_LOCAL_MACHINE" );
+                    }
+                break;
+            case(0):
+                    key = HKEY_CLASSES_ROOT;
+                    OutputDebugStringFormat(L"HKEY_CLASSES_ROOT" );
+                break;
+            case(1):
+                    key = HKEY_CURRENT_USER;
+                    OutputDebugStringFormat(L"HKEY_CURRENT_USER" );
+                break;
+            case(2):
+                    key = HKEY_LOCAL_MACHINE;
+                    OutputDebugStringFormat(L"HKEY_LOCAL_MACHINE" );
+                break;
+            case(3):
+                    key = HKEY_USERS;
+                    OutputDebugStringFormat(L"HKEY_USERS" );
+                break;
+
+        }
+        
+        OutputDebugStringFormat(L"Key:");
+        OutputDebugStringFormat( szKey );
+        OutputDebugStringFormat(L"Name:");
+        OutputDebugStringFormat( szName );
+        OutputDebugStringFormat(L"Value:");
+        OutputDebugStringFormat( szValue);
+        OutputDebugStringFormat(L"Component:");
+        OutputDebugStringFormat( szComponent );
+        OutputDebugStringFormat(L"*******************" );
+        switch (op)
+        {
+            case SET:
+                    
+                    if (WriteRegistry(rhMSI, SET, szComponent))
+                    {
+                        OutputDebugStringFormat(L"DoRegEntries - Write\n" );
+                        SetRegistryKey(key, szKey, szName, szValue);
+                    }
+                break;
+            case REMOVE: 
+                    OutputDebugStringFormat(L"DoRegEntries - PreRemove\n" );
+                    if (WriteRegistry(rhMSI, REMOVE, szComponent))
+                    {
+                        OutputDebugStringFormat(L"DoRegEntries - Remove\n" );
+                        DeleteRegistryKey(key, szKey);
+                    }
+                break;
+        }
+    }
+
+    MsiCloseHandle(rhView);
+    
+    
+    OutputDebugStringFormat(L"DoRegEntries - ENDE\n" );
+    
+    return true;
+}
+
+
+bool Reg64(MSIHANDLE& rhMSI, OPERATION op)
+{
+    isInstall4AllUsers = IsInstallForAllUsers(rhMSI);
+    sBasisInstallLocation = GetBasisInstallLocation(rhMSI);
+
+    if (NULL == sBasisInstallLocation)
+    {
+        OutputDebugStringFormat(L"BASISINSTALLLOCATION is NULL\n" );
+        return false;
+    }
+    
+    MSIHANDLE hView;
+    MSIHANDLE hDatabase = MsiGetActiveDatabase(rhMSI);
+
+    QueryReg64Table(hDatabase, hView);
+    OutputDebugStringFormat(L"Do something\n" );
+    DoRegEntries( rhMSI, op, hView);
+    OutputDebugStringFormat(L"Something done\n" );
+
+    MsiCloseHandle(hView);
+    MsiCloseHandle(hDatabase);
+    free(sBasisInstallLocation);
+
+    return true;
+}
+
+extern "C" UINT __stdcall InstallReg64(MSIHANDLE hMSI)
+{
+    OutputDebugStringFormat(L"InstallReg64\n" );
+    Reg64(hMSI, SET);
+    return ERROR_SUCCESS;    
+}
+
+extern "C" UINT __stdcall DeinstallReg64(MSIHANDLE hMSI)
+{
+    OutputDebugStringFormat(L"DeinstallReg64\n" );
+    Reg64(hMSI, REMOVE);
+    return ERROR_SUCCESS;
+}
\ No newline at end of file
diff --git a/setup_native/source/win32/customactions/regactivex/regactivex.cxx b/setup_native/source/win32/customactions/regactivex/regactivex.cxx
index 7797173..f057829 100644
--- a/setup_native/source/win32/customactions/regactivex/regactivex.cxx
+++ b/setup_native/source/win32/customactions/regactivex/regactivex.cxx
@@ -51,8 +51,8 @@
 
 // #define OWN_DEBUG_PRINT
 
-typedef int ( __stdcall * DllNativeRegProc ) ( int, BOOL, const char* );
-typedef int ( __stdcall * DllNativeUnregProc ) ( int, BOOL );
+typedef int ( __stdcall * DllNativeRegProc ) ( int, BOOL, BOOL, const char* );
+typedef int ( __stdcall * DllNativeUnregProc ) ( int, BOOL, BOOL );
 
 BOOL UnicodeEquals( wchar_t* pStr1, wchar_t* pStr2 )
 {
@@ -90,7 +90,7 @@ void WarningMessageInt( wchar_t* pWarning, unsigned int nValue )
 #endif
 
 //----------------------------------------------------------
-void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser )
+void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit )
 {
 #ifdef OWN_DEBUG_PRINT
     MessageBoxW(NULL, L"RegisterActiveXNative", L"Information", MB_OK | MB_ICONINFORMATION);
@@ -112,7 +112,18 @@ void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallFor
 #ifdef OWN_DEBUG_PRINT
             MessageBoxA(NULL, pActiveXPath, "Library Path", MB_OK | MB_ICONINFORMATION);
 #endif
-            ( *pNativeProc )( nMode, InstallForAllUser, pActiveXPath );
+            int nLen = strlen( pActiveXPath );
+            int nRemoveLen = strlen( "\\so_activex.dll" );
+            if ( nLen > nRemoveLen )
+            {
+                char* pProgramPath = reinterpret_cast<char*>( malloc( nLen - nRemoveLen + 1 ) );
+                strncpy( pProgramPath, pActiveXPath, nLen - nRemoveLen );
+                pProgramPath[ nLen - nRemoveLen ] = 0;
+
+                ( *pNativeProc )( nMode, InstallForAllUser, InstallFor64Bit, pProgramPath );
+
+                free( pProgramPath );
+            }
         }
 
         FreeLibrary( hModule );
@@ -120,7 +131,7 @@ void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallFor
 }
 
 //----------------------------------------------------------
-void UnregisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser )
+void UnregisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit )
 {
     // For Win98/WinME the values should be written to the local machine
     OSVERSIONINFO		aVerInfo;
@@ -133,7 +144,7 @@ void UnregisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallF
     {
         DllNativeUnregProc pNativeProc = ( DllNativeUnregProc )GetProcAddress( hModule, "DllUnregisterServerNative" );
         if( pNativeProc!=NULL )
-            ( *pNativeProc )( nMode, InstallForAllUser );
+            ( *pNativeProc )( nMode, InstallForAllUser, InstallFor64Bit );
 
         FreeLibrary( hModule );
     }
@@ -162,7 +173,7 @@ BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
 BOOL GetActiveXControlPath( MSIHANDLE hMSI, char** ppActiveXPath )
 {
     wchar_t* pProgPath = NULL;
-    if ( GetMsiProp( hMSI, L"BASISINSTALLLOCATION", &pProgPath ) && pProgPath )
+    if ( GetMsiProp( hMSI, L"OFFICEINSTALLLOCATION", &pProgPath ) && pProgPath )
        {
         char* pCharProgPath = UnicodeToAnsiString( pProgPath );
 #ifdef OWN_DEBUG_PRINT
@@ -313,6 +324,19 @@ BOOL MakeInstallForAllUsers( MSIHANDLE hMSI )
 }
 
 //----------------------------------------------------------
+BOOL MakeInstallFor64Bit( MSIHANDLE hMSI )
+{
+    BOOL bResult = FALSE;
+    wchar_t* pVal = NULL;
+    if ( GetMsiProp( hMSI, L"VersionNT64", &pVal ) && pVal )
+    {
+        bResult = TRUE;
+        free( pVal );
+    }
+
+    return bResult;
+}
+//----------------------------------------------------------
 extern "C" UINT __stdcall InstallActiveXControl( MSIHANDLE hMSI )
 {
     int nOldInstallMode = 0;
@@ -333,6 +357,8 @@ extern "C" UINT __stdcall InstallActiveXControl( MSIHANDLE hMSI )
 #endif
 
         BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI );
+        BOOL bInstallFor64Bit = MakeInstallFor64Bit( hMSI );
+
         char* pActiveXPath = NULL;
         if ( GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath
         && GetDelta( hMSI, nOldInstallMode, nInstallMode, nDeinstallMode ) )
@@ -351,10 +377,10 @@ extern "C" UINT __stdcall InstallActiveXControl( MSIHANDLE hMSI )
                 // the control is installed in the new selected configuration
 
                 if ( current_state == INSTALLSTATE_LOCAL && nDeinstallMode )
-                    UnregisterActiveXNative( pActiveXPath, nDeinstallMode, bInstallForAllUser );
+                    UnregisterActiveXNative( pActiveXPath, nDeinstallMode, bInstallForAllUser, bInstallFor64Bit );
 
                 if ( nInstallMode )
-                    RegisterActiveXNative( pActiveXPath, nInstallMode, bInstallForAllUser );
+                    RegisterActiveXNative( pActiveXPath, nInstallMode, bInstallForAllUser, bInstallFor64Bit );
             }
             else if ( current_state == INSTALLSTATE_LOCAL && future_state == INSTALLSTATE_ABSENT )
             {
@@ -362,7 +388,7 @@ extern "C" UINT __stdcall InstallActiveXControl( MSIHANDLE hMSI )
                 MessageBox(NULL, L"InstallActiveXControl, removing", L"Information", MB_OK | MB_ICONINFORMATION);
 #endif
                 if ( nOldInstallMode )
-                    UnregisterActiveXNative( pActiveXPath, nOldInstallMode, bInstallForAllUser );
+                    UnregisterActiveXNative( pActiveXPath, nOldInstallMode, bInstallForAllUser, bInstallFor64Bit );
             }
         }
 
@@ -393,6 +419,7 @@ extern "C" UINT __stdcall DeinstallActiveXControl( MSIHANDLE hMSI )
         if ( current_state == INSTALLSTATE_LOCAL && GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath )
         {
             BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI );
+            BOOL bInstallFor64Bit = MakeInstallFor64Bit( hMSI );
 
             {
                 UnregisterActiveXNative( pActiveXPath,
@@ -402,7 +429,8 @@ extern "C" UINT __stdcall DeinstallActiveXControl( MSIHANDLE hMSI )
                                         | CALC_COMPONENT
                                         | WRITER_COMPONENT
                                         | MATH_COMPONENT,
-                                        bInstallForAllUser );
+                                        bInstallForAllUser,
+                                        bInstallFor64Bit );
             }
 
             free( pActiveXPath );
diff --git a/setup_native/source/win32/customactions/shellextensions/shellextensions.cxx b/setup_native/source/win32/customactions/shellextensions/shellextensions.cxx
index 9c3665f..396c38d 100644
--- a/setup_native/source/win32/customactions/shellextensions/shellextensions.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/shellextensions.cxx
@@ -102,23 +102,96 @@ RegistryEntry InfotipHandler = { TEXT("{087B3AE3-E237-4467-B8DB-5A38AB959AC9}"),
 RegistryEntry PropHandler = { TEXT("{63542C48-9552-494A-84F7-73AA6A7C99C1}"), TEXT("OpenOffice.org Property Sheet Handler") };
 RegistryEntry ThumbViewer = { TEXT("{3B092F0C-7696-40E3-A80F-68D74DA84210}"), TEXT("OpenOffice.org Thumbnail Viewer") };
 
+BOOL GetMsiProp( MSIHANDLE hMSI, const char* pPropName, char** ppValue )
+{
+    DWORD sz = 0;
+       if ( MsiGetProperty( hMSI, pPropName, 0, &sz ) == ERROR_MORE_DATA )
+       {
+           sz++;
+           DWORD nbytes = sz * sizeof( char );
+           char* buff = reinterpret_cast<char*>( malloc( nbytes ) );
+           ZeroMemory( buff, nbytes );
+           MsiGetProperty( hMSI, pPropName, buff, &sz );
+           *ppValue = buff;
+
+        return TRUE;
+    }
+
+    return FALSE;
+} 
+
+bool IsVersionNT64( MSIHANDLE hMSI )
+{
+    char* pVal = NULL;
+
+    if ( GetMsiProp( hMSI, "VersionNT64", &pVal ) && pVal )
+    {
+        free( pVal );
+        return true;
+    }
+
+    return false;
+}
+
+
+
+
 /*
     Called during installation when the module "Windows Explorer Extensions" is
     selected.
 */
-extern "C" UINT __stdcall InstallExecSequenceEntry(MSIHANDLE)
+extern "C" UINT __stdcall InstallExecSequenceEntry(MSIHANDLE hMSI)
 {
     //MessageBox(NULL, TEXT("InstallExecSequenceEntry"), TEXT("Pythonmsi"), MB_OK | MB_ICONINFORMATION);
     HKEY hKey;
-    if (RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), &hKey) == ERROR_SUCCESS)
-    {            
-        RegSetValueEx(hKey, ColumnHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(ColumnHandler.Value), _tcslen(ColumnHandler.Value) + 1);        
-        RegSetValueEx(hKey, InfotipHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(InfotipHandler.Value), _tcslen(InfotipHandler.Value) + 1);            
-        RegSetValueEx(hKey, PropHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(PropHandler.Value), _tcslen(PropHandler.Value) + 1);    
-        RegSetValueEx(hKey, ThumbViewer.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(ThumbViewer.Value), _tcslen(ThumbViewer.Value) + 1);    
-    
-        RegCloseKey(hKey);
-    }                                
+
+
+// 06.11.2009 tkr: to provide windows xp as build systems for mingw we need to define KEY_WOW64_64KEY
+// in mingw 3.13 KEY_WOW64_64KEY isn't available < Win2003 systems.
+// Also defined in setup_native\source\win32\customactions\reg64\reg64.cxx,source\win32\customactions\shellextensions\shellextensions.cxx and
+// extensions\source\activex\main\so_activex.cpp
+#ifndef KEY_WOW64_64KEY
+    #define KEY_WOW64_64KEY	(0x0100)
+#endif
+
+    if (IsVersionNT64(hMSI))
+    {
+        // Open Windows 64 Bit Registry
+        if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),0, KEY_WRITE | KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS)
+        {            
+            RegSetValueEx(hKey, ColumnHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(ColumnHandler.Value), _tcslen(ColumnHandler.Value) + 1);        
+            RegSetValueEx(hKey, InfotipHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(InfotipHandler.Value), _tcslen(InfotipHandler.Value) + 1);            
+            RegSetValueEx(hKey, PropHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(PropHandler.Value), _tcslen(PropHandler.Value) + 1);    
+            RegSetValueEx(hKey, ThumbViewer.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(ThumbViewer.Value), _tcslen(ThumbViewer.Value) + 1);    
+        
+            RegCloseKey(hKey);
+        }         
+
+        // Open Windows 32 Bit Registry on Win64 maschine
+
+        if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),0, KEY_WRITE, &hKey ) == ERROR_SUCCESS)
+        {            
+            RegSetValueEx(hKey, ColumnHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(ColumnHandler.Value), _tcslen(ColumnHandler.Value) + 1);        
+            RegSetValueEx(hKey, InfotipHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(InfotipHandler.Value), _tcslen(InfotipHandler.Value) + 1);            
+            RegSetValueEx(hKey, PropHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(PropHandler.Value), _tcslen(PropHandler.Value) + 1);    
+            RegSetValueEx(hKey, ThumbViewer.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(ThumbViewer.Value), _tcslen(ThumbViewer.Value) + 1);    
+        
+            RegCloseKey(hKey);
+        }         
+
+
+    } else
+    {
+        if (RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), &hKey) == ERROR_SUCCESS)
+        {            
+            RegSetValueEx(hKey, ColumnHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(ColumnHandler.Value), _tcslen(ColumnHandler.Value) + 1);        
+            RegSetValueEx(hKey, InfotipHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(InfotipHandler.Value), _tcslen(InfotipHandler.Value) + 1);            
+            RegSetValueEx(hKey, PropHandler.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(PropHandler.Value), _tcslen(PropHandler.Value) + 1);    
+            RegSetValueEx(hKey, ThumbViewer.Key, 0, REG_SZ, reinterpret_cast<const BYTE*>(ThumbViewer.Value), _tcslen(ThumbViewer.Value) + 1);    
+        
+            RegCloseKey(hKey);
+        }         
+    }
     return ERROR_SUCCESS;    
 }
 


More information about the ooo-build-commit mailing list