diff options
author | Rüdiger Timm <rt@openoffice.org> | 2005-01-31 09:40:45 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2005-01-31 09:40:45 +0000 |
commit | b64e1e83a22d5d986f7af15650c84da8cb43a630 (patch) | |
tree | 763505ff487ffdde3d288c92b49e879f2eaf03e7 /setup_native/source | |
parent | 911abbf41c1fb09bb007aa07a8cb0aefc28f1a4a (diff) |
INTEGRATION: CWS nativefixer3 (1.1.2); FILE ADDED
2005/01/21 15:26:26 is 1.1.2.2: join to sysui03
2005/01/14 14:19:10 hro 1.1.2.1: #i40595# New custom action to customize start menu folder icon
Diffstat (limited to 'setup_native/source')
-rw-r--r-- | setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx b/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx new file mode 100644 index 000000000000..534d182d2d96 --- /dev/null +++ b/setup_native/source/win32/customactions/shellextensions/startmenuicon.cxx @@ -0,0 +1,154 @@ +/************************************************************************* + * + * $RCSfile: startmenuicon.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: rt $ $Date: 2005-01-31 10:40:45 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <msiquery.h> +#include <malloc.h> + +#ifdef UNICODE +#define _UNICODE +#define _tstring wstring +#else +#define _tstring string +#endif +#include <tchar.h> +#include <string> + +#ifdef _WIN32_WINNT +#error YES +#endif + +std::_tstring GetMsiProperty( MSIHANDLE handle, const std::_tstring& sProperty ) +{ + std::_tstring result; + TCHAR szDummy[1] = TEXT(""); + DWORD nChars = 0; + + if ( MsiGetProperty( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA ) + { + DWORD nBytes = ++nChars * sizeof(TCHAR); + LPTSTR buffer = reinterpret_cast<LPTSTR>(_alloca(nBytes)); + ZeroMemory( buffer, nBytes ); + MsiGetProperty(handle, sProperty.c_str(), buffer, &nChars); + result = buffer; + } + + return result; +} + +/* + Called during installation to customize the start menu folder icon. + See: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/custom.asp +*/ +extern "C" UINT __stdcall InstallStartmenuFolderIcon( MSIHANDLE handle ) +{ + std::_tstring sOfficeMenuFolder = GetMsiProperty( handle, TEXT("OfficeMenuFolder") ); + std::_tstring sDesktopFile = sOfficeMenuFolder + TEXT("Desktop.ini"); + +// MessageBox(NULL, sDesktopFile.c_str(), TEXT("OfficeMenuFolder"), MB_OK | MB_ICONINFORMATION); + + std::_tstring sIconFile = GetMsiProperty( handle, TEXT("INSTALLLOCATION") ) + TEXT("program\\soffice.exe"); + + WritePrivateProfileString( + TEXT(".ShellClassInfo"), + TEXT("IconFile"), + sIconFile.c_str(), + sDesktopFile.c_str() ); + + WritePrivateProfileString( + TEXT(".ShellClassInfo"), + TEXT("IconIndex"), + TEXT("0"), + sDesktopFile.c_str() ); + + WritePrivateProfileString( + TEXT(".ShellClassInfo"), + TEXT("ConfirmFileOp"), + TEXT("0"), + sDesktopFile.c_str() ); + + /* + WritePrivateProfileString( + TEXT(".ShellClassInfo"), + TEXT("InfoTip"), + TEXT("StarOffice Productivity Suite"), + sDesktopFile.c_str() ); + */ + + SetFileAttributes( sDesktopFile.c_str(), FILE_ATTRIBUTE_HIDDEN ); + SetFileAttributes( sOfficeMenuFolder.c_str(), FILE_ATTRIBUTE_SYSTEM ); + + return ERROR_SUCCESS; +} + +extern "C" UINT __stdcall DeinstallStartmenuFolderIcon(MSIHANDLE handle) +{ + std::_tstring sOfficeMenuFolder = GetMsiProperty( handle, TEXT("OfficeMenuFolder") ); + std::_tstring sDesktopFile = sOfficeMenuFolder + TEXT("Desktop.ini"); + + SetFileAttributes( sDesktopFile.c_str(), FILE_ATTRIBUTE_NORMAL ); + DeleteFile( sDesktopFile.c_str() ); + + SetFileAttributes( sOfficeMenuFolder.c_str(), FILE_ATTRIBUTE_NORMAL ); + + return ERROR_SUCCESS; +} |