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: iconcache.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 ************************************************************************/
32 #pragma warning(push, 1) /* disable warnings within system headers */
34 #define WIN32_LEAN_AND_MEAN
43 extern "C" UINT __stdcall
RebuildShellIconCache(MSIHANDLE
)
45 // Rebuild icon cache on windows OS prior XP
47 OSVERSIONINFO osverinfo
;
49 osverinfo
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
52 GetVersionEx( &osverinfo
) &&
53 VER_PLATFORM_WIN32_NT
== osverinfo
.dwPlatformId
&&
55 5 < osverinfo
.dwMajorVersion
||
56 5 == osverinfo
.dwMajorVersion
&& 0 < osverinfo
.dwMinorVersion
65 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
);
67 if ( ERROR_SUCCESS
== lError
)
70 TCHAR szTempValue
[256];
71 DWORD cbValue
= sizeof(szValue
);
75 lError
= RegQueryValueEx( hKey
, TEXT("Shell Icon Size"), 0, &dwType
, (LPBYTE
)szValue
, &cbValue
);
77 if ( ERROR_SUCCESS
== lError
)
78 iSize
= atoi( szValue
);
82 iSize
= GetSystemMetrics( SM_CXICON
);
83 itoa( iSize
, szValue
, 10 );
84 cbValue
= strlen( szValue
) + 1;
88 itoa( iSize
+ 1, szTempValue
, 10 );
89 lError
= RegSetValueEx( hKey
, TEXT("Shell Icon Size"), 0, dwType
, (LPBYTE
)szTempValue
, strlen( szTempValue
) + 1 );
91 LRESULT lResult
= SendMessageTimeout(
94 SPI_SETNONCLIENTMETRICS
,
95 (LPARAM
)TEXT("WindowMetrics"),
96 SMTO_NORMAL
|SMTO_ABORTIFHUNG
,
99 lError
= RegSetValueEx( hKey
, TEXT("Shell Icon Size"), 0, dwType
, (LPBYTE
)szValue
, cbValue
);
101 lResult
= SendMessageTimeout(
104 SPI_SETNONCLIENTMETRICS
,
105 (LPARAM
)TEXT("WindowMetrics"),
106 SMTO_NORMAL
|SMTO_ABORTIFHUNG
,
109 lError
= RegCloseKey( hKey
);
112 return ERROR_SUCCESS
;