Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / setup_native / source / win32 / customactions / shellextensions / iconcache.cxx
blobdaba7fb8c7d70dd2944cf882be7e65ada8ab328d
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 #ifdef _MSC_VER
30 #pragma warning(push, 1) /* disable warnings within system headers */
31 #endif
32 #define WIN32_LEAN_AND_MEAN
33 #include <windows.h>
34 #include <msiquery.h>
35 #ifdef _MSC_VER
36 #pragma warning(pop)
37 #endif
39 #include <stdlib.h>
41 extern "C" UINT __stdcall RebuildShellIconCache(MSIHANDLE)
43 // Rebuild icon cache on windows OS prior XP
45 OSVERSIONINFO osverinfo;
47 osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
49 if (
50 GetVersionEx( &osverinfo ) &&
51 VER_PLATFORM_WIN32_NT == osverinfo.dwPlatformId &&
53 5 < osverinfo.dwMajorVersion ||
54 5 == osverinfo.dwMajorVersion && 0 < osverinfo.dwMinorVersion
58 return ERROR_SUCCESS;
61 HKEY hKey;
62 DWORD dwDispostion;
63 LONG lError = RegCreateKeyEx( HKEY_CURRENT_USER, TEXT("Control Panel\\Desktop\\WindowMetrics"), 0, NULL, REG_OPTION_VOLATILE, KEY_SET_VALUE | KEY_QUERY_VALUE, NULL, &hKey, &dwDispostion );
65 if ( ERROR_SUCCESS == lError )
67 TCHAR szValue[256];
68 TCHAR szTempValue[256];
69 DWORD cbValue = sizeof(szValue);
70 DWORD dwType;
71 int iSize = 0;
73 lError = RegQueryValueEx( hKey, TEXT("Shell Icon Size"), 0, &dwType, (LPBYTE)szValue, &cbValue );
75 if ( ERROR_SUCCESS == lError )
76 iSize = atoi( szValue );
78 if ( !iSize )
80 iSize = GetSystemMetrics( SM_CXICON );
81 itoa( iSize, szValue, 10 );
82 cbValue = strlen( szValue ) + 1;
83 dwType = REG_SZ;
86 itoa( iSize + 1, szTempValue, 10 );
87 lError = RegSetValueEx( hKey, TEXT("Shell Icon Size"), 0, dwType, (LPBYTE)szTempValue, strlen( szTempValue ) + 1 );
89 LRESULT lResult = SendMessageTimeout(
90 HWND_BROADCAST,
91 WM_SETTINGCHANGE,
92 SPI_SETNONCLIENTMETRICS,
93 (LPARAM)TEXT("WindowMetrics"),
94 SMTO_NORMAL|SMTO_ABORTIFHUNG,
95 0, NULL);
97 lError = RegSetValueEx( hKey, TEXT("Shell Icon Size"), 0, dwType, (LPBYTE)szValue, cbValue );
99 lResult = SendMessageTimeout(
100 HWND_BROADCAST,
101 WM_SETTINGCHANGE,
102 SPI_SETNONCLIENTMETRICS,
103 (LPARAM)TEXT("WindowMetrics"),
104 SMTO_NORMAL|SMTO_ABORTIFHUNG,
105 0, NULL);
107 lError = RegCloseKey( hKey );
110 return ERROR_SUCCESS;
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */