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 ************************************************************************/
30 #pragma warning(push, 1) /* disable warnings within system headers */
32 #define WIN32_LEAN_AND_MEAN
41 extern "C" UINT __stdcall
RebuildShellIconCache(MSIHANDLE
)
43 // Rebuild icon cache on windows OS prior XP
45 OSVERSIONINFO osverinfo
;
47 osverinfo
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
50 GetVersionEx( &osverinfo
) &&
51 VER_PLATFORM_WIN32_NT
== osverinfo
.dwPlatformId
&&
53 5 < osverinfo
.dwMajorVersion
||
54 5 == osverinfo
.dwMajorVersion
&& 0 < osverinfo
.dwMinorVersion
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
)
68 TCHAR szTempValue
[256];
69 DWORD cbValue
= sizeof(szValue
);
73 lError
= RegQueryValueEx( hKey
, TEXT("Shell Icon Size"), 0, &dwType
, (LPBYTE
)szValue
, &cbValue
);
75 if ( ERROR_SUCCESS
== lError
)
76 iSize
= atoi( szValue
);
80 iSize
= GetSystemMetrics( SM_CXICON
);
81 itoa( iSize
, szValue
, 10 );
82 cbValue
= strlen( szValue
) + 1;
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(
92 SPI_SETNONCLIENTMETRICS
,
93 (LPARAM
)TEXT("WindowMetrics"),
94 SMTO_NORMAL
|SMTO_ABORTIFHUNG
,
97 lError
= RegSetValueEx( hKey
, TEXT("Shell Icon Size"), 0, dwType
, (LPBYTE
)szValue
, cbValue
);
99 lResult
= SendMessageTimeout(
102 SPI_SETNONCLIENTMETRICS
,
103 (LPARAM
)TEXT("WindowMetrics"),
104 SMTO_NORMAL
|SMTO_ABORTIFHUNG
,
107 lError
= RegCloseKey( hKey
);
110 return ERROR_SUCCESS
;
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */