* Sync with recent trunk (r52637).
[reactos.git] / base / applications / mspaint / registry.c
1 /*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL
4 * FILE: base/applications/paint/registry.c
5 * PURPOSE: Offering functions dealing with registry values
6 * PROGRAMMERS: Benedikt Freisen
7 */
8
9 /* INCLUDES *********************************************************/
10
11 #include <windows.h>
12 #include <tchar.h>
13
14 /* FUNCTIONS ********************************************************/
15
16 void
17 SetWallpaper(TCHAR * FileName, DWORD dwStyle, DWORD dwTile) //FIXME: Has to be called 2x to apply the pattern (tiled/stretched) too
18 {
19 HKEY hDesktop;
20 TCHAR szStyle[3], szTile[3];
21
22 SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID) FileName, SPIF_UPDATEINIFILE);
23
24 if ((dwStyle > 2) || (dwTile > 2))
25 return;
26
27 if (RegOpenKeyEx(HKEY_CURRENT_USER,
28 _T("Control Panel\\Desktop"), 0, KEY_READ | KEY_SET_VALUE, &hDesktop) == ERROR_SUCCESS)
29 {
30 RegSetValueEx(hDesktop, _T("Wallpaper"), 0, REG_SZ, (LPBYTE) FileName,
31 _tcslen(FileName) * sizeof(TCHAR));
32
33 _stprintf(szStyle, _T("%i"), dwStyle);
34 _stprintf(szTile, _T("%i"), dwTile);
35
36 RegSetValueEx(hDesktop, _T("WallpaperStyle"), 0, REG_SZ, (LPBYTE) szStyle,
37 _tcslen(szStyle) * sizeof(TCHAR));
38 RegSetValueEx(hDesktop, _T("TileWallpaper"), 0, REG_SZ, (LPBYTE) szTile,
39 _tcslen(szTile) * sizeof(TCHAR));
40
41 RegCloseKey(hDesktop);
42 }
43 }