LibreOffice Module setup_native (master) 1
startmenuicon.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include "shlxtmsi.hxx"
21
22#include <malloc.h>
23
24/*
25 Called during installation to customize the start menu folder icon.
26 See: http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/custom.asp
27*/
28extern "C" __declspec(dllexport) UINT __stdcall InstallStartmenuFolderIcon( MSIHANDLE handle )
29{
30 std::wstring sOfficeMenuFolder = GetMsiPropertyW( handle, L"OfficeMenuFolder" );
31 std::wstring sDesktopFile = sOfficeMenuFolder + L"Desktop.ini";
32
33 // at the moment there exists no Vista Icon, so we use the default folder icon.
34 // add the icon into desktop/util/verinfo.rc
35
36 // The value '0' is to avoid a message like "You Are Deleting a System Folder" warning when deleting or moving the folder.
37 WritePrivateProfileStringW(
38 L".ShellClassInfo",
39 L"ConfirmFileOp",
40 L"0",
41 sDesktopFile.c_str() );
42
43 SetFileAttributesW( sDesktopFile.c_str(), FILE_ATTRIBUTE_HIDDEN );
44 SetFileAttributesW( sOfficeMenuFolder.c_str(), FILE_ATTRIBUTE_SYSTEM );
45
46
47 return ERROR_SUCCESS;
48}
49
50extern "C" __declspec(dllexport) UINT __stdcall DeinstallStartmenuFolderIcon(MSIHANDLE handle)
51{
52 std::wstring sOfficeMenuFolder = GetMsiPropertyW( handle, L"OfficeMenuFolder" );
53 std::wstring sDesktopFile = sOfficeMenuFolder + L"Desktop.ini";
54
55 SetFileAttributesW( sDesktopFile.c_str(), FILE_ATTRIBUTE_NORMAL );
56 DeleteFileW( sDesktopFile.c_str() );
57
58 SetFileAttributesW( sOfficeMenuFolder.c_str(), FILE_ATTRIBUTE_NORMAL );
59
60 return ERROR_SUCCESS;
61}
62
63/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::wstring GetMsiPropertyW(MSIHANDLE handle, const std::wstring &sProperty)
Definition: shlxtmsi.hxx:29
__declspec(dllexport) UINT __stdcall InstallStartmenuFolderIcon(MSIHANDLE handle)