Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1004276 // Try Setting Desktop Wallpaper On Windows [Works on XP!]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1289L/9K/31K).

!752

p {
  S imageID = or2(get(args, 0), "#1002132"); // Eleutheria
  File img = prepareProgramFile(parseSnippetID(imageID) + ".bmp");
  saveBMP(loadImage2(imageID), img);
  assertTrue(img.getAbsolutePath(), img.isFile());
  
  backtick_verbose = true;
  
  S cmd = "reg add \"HKEY_CURRENT_USER\\Control Panel\\Desktop\" /v Wallpaper /t REG_SZ /d " + bashQuote(img) + " /f";
  backtick(cmd);
  
  // Set to "fit" (WallpaperStyle=6, TileWallpaper=0) doesn't seem to work
  // So set to "center"
  cmd = "reg add \"HKEY_CURRENT_USER\\Control Panel\\Desktop\" /v WallpaperStyle /t REG_SZ /d " + 0 + " /f";
  backtick(cmd);
  cmd = "reg add \"HKEY_CURRENT_USER\\Control Panel\\Desktop\" /v TileWallpaper /t REG_SZ /d " + 0 + " /f";
  backtick(cmd);

  cmd = "RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters";
  backtick(cmd);
  
  print("Wallpaper set to " + imageID + "!?");
}

Author comment

Began life as a copy of #1004272

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, etmzoiygucik, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004276
Snippet name: Try Setting Desktop Wallpaper On Windows [Works on XP!]
Eternal ID of this version: #1004276/1
Text MD5: c131941a4574e6afdab31bf537547f1a
Transpilation MD5: a7b271f358a1b4409c8a712559b37921
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-12 17:23:47
Source code size: 905 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 432 / 513
Referenced in: [show references]