1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifdef _MSC_VER 29 #pragma warning(push, 1) /* disable warnings within system headers */ 30 #endif 31 #define WIN32_LEAN_AND_MEAN 32 #include <windows.h> 33 #include <msiquery.h> 34 #ifdef _MSC_VER 35 #pragma warning(pop) 36 #endif 37 38 #include <stdlib.h> 39 40 extern "C" UINT __stdcall RebuildShellIconCache(MSIHANDLE) 41 { 42 // Rebuild icon cache on windows OS prior XP 43 44 OSVERSIONINFO osverinfo; 45 46 osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 47 48 if ( 49 GetVersionEx( &osverinfo ) && 50 VER_PLATFORM_WIN32_NT == osverinfo.dwPlatformId && 51 ( 52 5 < osverinfo.dwMajorVersion || 53 5 == osverinfo.dwMajorVersion && 0 < osverinfo.dwMinorVersion 54 ) 55 ) 56 { 57 return ERROR_SUCCESS; 58 } 59 60 HKEY hKey; 61 DWORD dwDispostion; 62 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 ); 63 64 if ( ERROR_SUCCESS == lError ) 65 { 66 TCHAR szValue[256]; 67 TCHAR szTempValue[256]; 68 DWORD cbValue = sizeof(szValue); 69 DWORD dwType; 70 int iSize = 0; 71 72 lError = RegQueryValueEx( hKey, TEXT("Shell Icon Size"), 0, &dwType, (LPBYTE)szValue, &cbValue ); 73 74 if ( ERROR_SUCCESS == lError ) 75 iSize = atoi( szValue ); 76 77 if ( !iSize ) 78 { 79 iSize = GetSystemMetrics( SM_CXICON ); 80 itoa( iSize, szValue, 10 ); 81 cbValue = strlen( szValue ) + 1; 82 dwType = REG_SZ; 83 } 84 85 itoa( iSize + 1, szTempValue, 10 ); 86 lError = RegSetValueEx( hKey, TEXT("Shell Icon Size"), 0, dwType, (LPBYTE)szTempValue, strlen( szTempValue ) + 1 ); 87 88 LRESULT lResult = SendMessageTimeout( 89 HWND_BROADCAST, 90 WM_SETTINGCHANGE, 91 SPI_SETNONCLIENTMETRICS, 92 (LPARAM)TEXT("WindowMetrics"), 93 SMTO_NORMAL|SMTO_ABORTIFHUNG, 94 0, NULL); 95 96 lError = RegSetValueEx( hKey, TEXT("Shell Icon Size"), 0, dwType, (LPBYTE)szValue, cbValue ); 97 98 lResult = SendMessageTimeout( 99 HWND_BROADCAST, 100 WM_SETTINGCHANGE, 101 SPI_SETNONCLIENTMETRICS, 102 (LPARAM)TEXT("WindowMetrics"), 103 SMTO_NORMAL|SMTO_ABORTIFHUNG, 104 0, NULL); 105 106 lError = RegCloseKey( hKey ); 107 } 108 109 return ERROR_SUCCESS; 110 } 111