1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #define _WIN32_WINDOWS 0x0410
32 #pragma warning(push, 1) /* disable warnings within system headers */
34 #define WIN32_LEAN_AND_MEAN
45 #define _tstring wstring
47 #define _tstring string
53 std::_tstring
GetMsiProperty( MSIHANDLE handle
, const std::_tstring
& sProperty
)
56 TCHAR szDummy
[1] = TEXT("");
59 if ( MsiGetProperty( handle
, sProperty
.c_str(), szDummy
, &nChars
) == ERROR_MORE_DATA
)
61 DWORD nBytes
= ++nChars
* sizeof(TCHAR
);
62 LPTSTR buffer
= reinterpret_cast<LPTSTR
>(_alloca(nBytes
));
63 ZeroMemory( buffer
, nBytes
);
64 MsiGetProperty(handle
, sProperty
.c_str(), buffer
, &nChars
);
72 Called during installation to customize the start menu folder icon.
73 See: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/custom.asp
75 extern "C" UINT __stdcall
InstallStartmenuFolderIcon( MSIHANDLE handle
)
77 std::_tstring sOfficeMenuFolder
= GetMsiProperty( handle
, TEXT("OfficeMenuFolder") );
78 std::_tstring sDesktopFile
= sOfficeMenuFolder
+ TEXT("Desktop.ini");
79 std::_tstring sIconFile
= GetMsiProperty( handle
, TEXT("INSTALLLOCATION") ) + TEXT("program\\soffice.exe");
81 OSVERSIONINFO osverinfo
;
82 osverinfo
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
83 GetVersionEx( &osverinfo
);
85 if (osverinfo
.dwMajorVersion
< 6 /* && osverinfo.dwMinorVersion */ )
87 WritePrivateProfileString(
88 TEXT(".ShellClassInfo"),
91 sDesktopFile
.c_str() );
93 WritePrivateProfileString(
94 TEXT(".ShellClassInfo"),
97 sDesktopFile
.c_str() );
101 // // at the moment there exists no Vista Icon, so we use the default folder icon.
102 // // add the icon into desktop/util/verinfo.rc
105 // The value '0' is to avoid a message like "You Are Deleting a System Folder" warning when deleting or moving the folder.
106 WritePrivateProfileString(
107 TEXT(".ShellClassInfo"),
108 TEXT("ConfirmFileOp"),
110 sDesktopFile
.c_str() );
112 SetFileAttributes( sDesktopFile
.c_str(), FILE_ATTRIBUTE_HIDDEN
);
113 SetFileAttributes( sOfficeMenuFolder
.c_str(), FILE_ATTRIBUTE_SYSTEM
);
116 return ERROR_SUCCESS
;
119 extern "C" UINT __stdcall
DeinstallStartmenuFolderIcon(MSIHANDLE handle
)
121 std::_tstring sOfficeMenuFolder
= GetMsiProperty( handle
, TEXT("OfficeMenuFolder") );
122 std::_tstring sDesktopFile
= sOfficeMenuFolder
+ TEXT("Desktop.ini");
124 SetFileAttributes( sDesktopFile
.c_str(), FILE_ATTRIBUTE_NORMAL
);
125 DeleteFile( sDesktopFile
.c_str() );
127 SetFileAttributes( sOfficeMenuFolder
.c_str(), FILE_ATTRIBUTE_NORMAL
);
129 return ERROR_SUCCESS
;
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */