1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: shellextensions.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 Windows shell extensions need to be approved in order to be used by the
33 Windows shell for clarification read the following section from the
34 Microsoft Developers Network Library (MSDN) see
35 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_extending/extensionhandlers/shell_ext.asp
39 Shell extension handlers run in the Shell process. Because it is a system process,
40 the administrator of a Windows NT system can limit Shell extension handlers to
41 those on an approved list by setting the EnforceShellExtensionSecurity value of the
42 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer key to 1
44 To place a Shell extension handler on the approved list, create a REG_SZ value whose
45 name is the string form of the handler's GUID under
46 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved.
48 The Shell does not use the value that is assigned to the GUID, but it should be set to
49 make inspecting the registry easier.
51 Your setup application can add values to the Approved key only if the person installing
52 the application has sufficient privileges. If the attempt to add an extension handler
53 fails, you should inform the user that administrative privileges are required to fully
54 install the application. If the handler is essential to the application, you should fail
55 the setup and notify the user to contact an administrator.
57 While there is no need to add values to the Approved key on Windows 95 or Windows 98
58 systems, there is no harm in doing so. The system will simply ignore them. However, there
59 is no guarantee that the key will exist on these systems. Your setup program must be able
63 We add the following entries to the respective registry key
64 "{C52AF81D-F7A0-4AAB-8E87-F80A60CCD396}"="OpenOffice.org Column Handler"
65 "{087B3AE3-E237-4467-B8DB-5A38AB959AC9}"="OpenOffice.org Infotip Handler"
66 "{63542C48-9552-494A-84F7-73AA6A7C99C1}"="OpenOffice.org Property Sheet Handler"
67 "{3B092F0C-7696-40E3-A80F-68D74DA84210}"="OpenOffice.org Thumbnail Viewer"
69 These shell extensions are implemented in the 'shell' project. We ignore registration
70 failures because of insufficient privileges. The reason is: On systems which restrict the
71 use of shell extensions by applying the aforementioned policy probably only people with
72 sufficient privileges are allowed to install applications anyway. On systems where the
73 use of shell extensions is not restricted registration failures because of insufficient
74 prviliges have no negative effect because the shell extensions will work anyhow.
78 #pragma warning(push, 1) /* disable warnings within system headers */
80 #define WIN32_LEAN_AND_MEAN
100 RegistryEntry ColumnHandler
= { TEXT("{C52AF81D-F7A0-4AAB-8E87-F80A60CCD396}"), TEXT("OpenOffice.org Column Handler") };
101 RegistryEntry InfotipHandler
= { TEXT("{087B3AE3-E237-4467-B8DB-5A38AB959AC9}"), TEXT("OpenOffice.org Infotip Handler") };
102 RegistryEntry PropHandler
= { TEXT("{63542C48-9552-494A-84F7-73AA6A7C99C1}"), TEXT("OpenOffice.org Property Sheet Handler") };
103 RegistryEntry ThumbViewer
= { TEXT("{3B092F0C-7696-40E3-A80F-68D74DA84210}"), TEXT("OpenOffice.org Thumbnail Viewer") };
106 Called during installation when the module "Windows Explorer Extensions" is
109 extern "C" UINT __stdcall
InstallExecSequenceEntry(MSIHANDLE
)
111 //MessageBox(NULL, TEXT("InstallExecSequenceEntry"), TEXT("Pythonmsi"), MB_OK | MB_ICONINFORMATION);
113 if (RegOpenKey(HKEY_LOCAL_MACHINE
, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), &hKey
) == ERROR_SUCCESS
)
115 RegSetValueEx(hKey
, ColumnHandler
.Key
, 0, REG_SZ
, reinterpret_cast<const BYTE
*>(ColumnHandler
.Value
), _tcslen(ColumnHandler
.Value
) + 1);
116 RegSetValueEx(hKey
, InfotipHandler
.Key
, 0, REG_SZ
, reinterpret_cast<const BYTE
*>(InfotipHandler
.Value
), _tcslen(InfotipHandler
.Value
) + 1);
117 RegSetValueEx(hKey
, PropHandler
.Key
, 0, REG_SZ
, reinterpret_cast<const BYTE
*>(PropHandler
.Value
), _tcslen(PropHandler
.Value
) + 1);
118 RegSetValueEx(hKey
, ThumbViewer
.Key
, 0, REG_SZ
, reinterpret_cast<const BYTE
*>(ThumbViewer
.Value
), _tcslen(ThumbViewer
.Value
) + 1);
122 return ERROR_SUCCESS
;
126 Called during deinstallation when the module "Windows Explorer Extensions" has
129 extern "C" UINT __stdcall
DeinstallExecSequenceEntry(MSIHANDLE
)
131 //MessageBox(NULL, TEXT("DeinstallExecSequenceEntry"), TEXT("Pythonmsi"), MB_OK | MB_ICONINFORMATION);
133 if (RegOpenKey(HKEY_LOCAL_MACHINE
, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"), &hKey
) == ERROR_SUCCESS
)
135 RegDeleteValue(hKey
, ColumnHandler
.Key
);
136 RegDeleteValue(hKey
, InfotipHandler
.Key
);
137 RegDeleteValue(hKey
, PropHandler
.Key
);
138 RegDeleteValue(hKey
, ThumbViewer
.Key
);
142 return ERROR_SUCCESS
;