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: startmenuicon.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 ************************************************************************/
31 #define _WIN32_WINDOWS 0x0410
34 #pragma warning(push, 1) /* disable warnings within system headers */
36 #define WIN32_LEAN_AND_MEAN
47 #define _tstring wstring
49 #define _tstring string
55 std::_tstring
GetMsiProperty( MSIHANDLE handle
, const std::_tstring
& sProperty
)
58 TCHAR szDummy
[1] = TEXT("");
61 if ( MsiGetProperty( handle
, sProperty
.c_str(), szDummy
, &nChars
) == ERROR_MORE_DATA
)
63 DWORD nBytes
= ++nChars
* sizeof(TCHAR
);
64 LPTSTR buffer
= reinterpret_cast<LPTSTR
>(_alloca(nBytes
));
65 ZeroMemory( buffer
, nBytes
);
66 MsiGetProperty(handle
, sProperty
.c_str(), buffer
, &nChars
);
74 Called during installation to customize the start menu folder icon.
75 See: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/custom.asp
77 extern "C" UINT __stdcall
InstallStartmenuFolderIcon( MSIHANDLE handle
)
79 std::_tstring sOfficeMenuFolder
= GetMsiProperty( handle
, TEXT("OfficeMenuFolder") );
80 std::_tstring sDesktopFile
= sOfficeMenuFolder
+ TEXT("Desktop.ini");
82 // MessageBox(NULL, sDesktopFile.c_str(), TEXT("OfficeMenuFolder"), MB_OK | MB_ICONINFORMATION);
84 std::_tstring sIconFile
= GetMsiProperty( handle
, TEXT("OFFICEINSTALLLOCATION") ) + TEXT("program\\soffice.exe");
86 OSVERSIONINFO osverinfo
;
87 osverinfo
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
88 GetVersionEx( &osverinfo
);
90 if (osverinfo
.dwMajorVersion
< 6 /* && osverinfo.dwMinorVersion */ )
92 // This icon (18) is a Windows folder until XP Version (number is 0 based)
93 WritePrivateProfileString(
94 TEXT(".ShellClassInfo"),
97 sDesktopFile
.c_str() );
99 // FYI: in tool 'ResHack' this icon can be found on position '19' (number is 1 based)
100 WritePrivateProfileString(
101 TEXT(".ShellClassInfo"),
104 sDesktopFile
.c_str() );
108 // // at the moment there exists no Vista Icon, so we use the default folder icon.
109 // // add the icon into desktop/util/verinfo.rc
112 // The value '0' is to avoid a message like "You Are Deleting a System Folder" warning when deleting or moving the folder.
113 WritePrivateProfileString(
114 TEXT(".ShellClassInfo"),
115 TEXT("ConfirmFileOp"),
117 sDesktopFile
.c_str() );
120 WritePrivateProfileString(
121 TEXT(".ShellClassInfo"),
123 TEXT("StarOffice Productivity Suite"),
124 sDesktopFile.c_str() );
127 SetFileAttributes( sDesktopFile
.c_str(), FILE_ATTRIBUTE_HIDDEN
);
128 SetFileAttributes( sOfficeMenuFolder
.c_str(), FILE_ATTRIBUTE_SYSTEM
);
131 return ERROR_SUCCESS
;
134 extern "C" UINT __stdcall
DeinstallStartmenuFolderIcon(MSIHANDLE handle
)
136 std::_tstring sOfficeMenuFolder
= GetMsiProperty( handle
, TEXT("OfficeMenuFolder") );
137 std::_tstring sDesktopFile
= sOfficeMenuFolder
+ TEXT("Desktop.ini");
139 SetFileAttributes( sDesktopFile
.c_str(), FILE_ATTRIBUTE_NORMAL
);
140 DeleteFile( sDesktopFile
.c_str() );
142 SetFileAttributes( sOfficeMenuFolder
.c_str(), FILE_ATTRIBUTE_NORMAL
);
144 return ERROR_SUCCESS
;