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