239{
243
244 char path[MAX_PATH];
245 if (
IsInString(wpPath,
":")) strcpy(path, wpPath);
247 {
249 strcat(path, "\\");
250 strcat(path, wpPath);
251 }
253 {
255 strcat(path, "\\");
256 strcat(path, wpPath);
257 }
258
260 {
262 sprintf(msg, "Error setting the desktop wallpaper - File not found! (%s).", path);
264 return;
265 }
266
267
268
269 int pointer = strlen(path) - 4;
270
271
272
273 if (!_stricmp(&path[pointer], ".jpg")
274 || !_stricmp(&path[pointer], ".png")
275 || !_stricmp(&path[pointer], ".bmp")
276 || !_stricmp(&path[pointer], "jpeg"))
277 {
278
279
280
281
282
283
284 char wallpaperStyle[10];
285
286
287
288
289 HKEY key;
290 if (RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop\\", 0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS)
291 {
292 LSTATUS result;
294 {
295 result = RegSetValueEx(key, "WallpaperStyle", 0, REG_SZ, (unsigned char*)"0", 2);
296 result = RegSetValueEx(key, "TileWallpaper", 0, REG_SZ, (unsigned char*)"1", 2);
297 strcpy(wallpaperStyle, "tiled");
298 }
300 {
301 result = RegSetValueEx(key, "WallpaperStyle", 0, REG_SZ, (unsigned char*)"1", 2);
302 result = RegSetValueEx(key, "TileWallpaper", 0, REG_SZ, (unsigned char*)"0", 2);
303 strcpy(wallpaperStyle, "centered");
304 }
306 {
307 result = RegSetValueEx(key, "WallpaperStyle", 0, REG_SZ, (unsigned char*)"22", 2);
308 result = RegSetValueEx(key, "TileWallpaper", 0, REG_SZ, (unsigned char*)"0", 2);
309 strcpy(wallpaperStyle, "spanned");
310 }
311 else
312 {
313 result = RegSetValueEx(key, "WallpaperStyle", 0, REG_SZ, (unsigned char*)"2", 2);
314 result = RegSetValueEx(key, "TileWallpaper", 0, REG_SZ, (unsigned char*)"0", 2);
315 strcpy(wallpaperStyle, "stretched");
316 }
317
318 RegCloseKey(key);
319
320 if (result != ERROR_SUCCESS)
321 {
323 return;
324 }
325 }
326 else
327 {
329 return;
330 }
331
332
334 {
335 char msg[1024];
338 else sprintf(msg, "Setting the desktop wallpaper to %s (%s).", path, wallpaperStyle);
340 }
341 SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)path, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
342
344 {
345
346
347 char* stylePtr = wpStyle;
348 if (wpStyle[0] == '-') stylePtr++;
352 else sprintf(rootCmd, "rootCommand: bsetbg -%s \"%s\"", stylePtr, path);
354
355
357 }
358 }
360}
bool FileExists(LPCSTR szFileName)
Definition BBApi.cpp:819
LPSTR StrRemoveEncap(LPSTR string)
Definition BBApi.cpp:406
void ReplaceEnvVars(LPSTR string)
Definition BBApi.cpp:2594
void ReplaceShellFolders(LPSTR string)
Definition BBApi.cpp:2633
char SF_currentThemePath[MAX_PATH]
Definition Settings.h:385
char wallpapersFolder[MAX_PATH]
Definition Settings.h:321
char SF_blackboxPath[MAX_PATH]
Definition Settings.h:377