Create a branch for console restructuration work.
[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 "precomp.h"
12
13 #include <winreg.h>
14
15 /* FUNCTIONS ********************************************************/
16
17 void
18 SetWallpaper(TCHAR * FileName, DWORD dwStyle, DWORD dwTile) //FIXME: Has to be called 2x to apply the pattern (tiled/stretched) too
19 {
20 HKEY hDesktop;
21 TCHAR szStyle[3], szTile[3];
22
23 SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID) FileName, SPIF_UPDATEINIFILE);
24
25 if ((dwStyle > 2) || (dwTile > 2))
26 return;
27
28 if (RegOpenKeyEx(HKEY_CURRENT_USER,
29 _T("Control Panel\\Desktop"), 0, KEY_READ | KEY_SET_VALUE, &hDesktop) == ERROR_SUCCESS)
30 {
31 RegSetValueEx(hDesktop, _T("Wallpaper"), 0, REG_SZ, (LPBYTE) FileName,
32 _tcslen(FileName) * sizeof(TCHAR));
33
34 _stprintf(szStyle, _T("%lu"), dwStyle);
35 _stprintf(szTile, _T("%lu"), dwTile);
36
37 RegSetValueEx(hDesktop, _T("WallpaperStyle"), 0, REG_SZ, (LPBYTE) szStyle,
38 _tcslen(szStyle) * sizeof(TCHAR));
39 RegSetValueEx(hDesktop, _T("TileWallpaper"), 0, REG_SZ, (LPBYTE) szTile,
40 _tcslen(szTile) * sizeof(TCHAR));
41
42 RegCloseKey(hDesktop);
43 }
44 }