Setting the wallpaper in Windows using Java -


i'm trying set wallpaper in windows 7 using java. i've tried using code answers here , here. works in windows 8 , 10, not in 7. there no errors, doesn't anything. i've tried setting different 1920x1080 wallpapers (that's resolution set in control panel) , different file formats (png, jpg, bmp) , running program on few different computers. code have after line that's supposed set wallpaper runs fine. i'm using jna version 4.2.0 , java 8 update 60.

is there way can set wallpaper in windows 7 using java?

edit:

here's code:

import java.util.hashmap;  import com.sun.jna.native; import com.sun.jna.platform.win32.windef.uint_ptr; import com.sun.jna.win32.stdcalllibrary; import com.sun.jna.win32.w32apifunctionmapper; import com.sun.jna.win32.w32apitypemapper;  public class wallpaperchanger {      public interface spi extends stdcalllibrary {          long spi_setdeskwallpaper = 20;         long spif_updateinifile = 0x01;         long spif_sendwininichange = 0x02;          @suppresswarnings("serial")         spi instance = (spi) native.loadlibrary("user32", spi.class,                 new hashmap<object, object>() {                     {                         put(option_type_mapper, w32apitypemapper.unicode);                         put(option_function_mapper,                                 w32apifunctionmapper.unicode);                     }                 });          boolean systemparametersinfo(uint_ptr uiaction, uint_ptr uiparam,                 string pvparam, uint_ptr fwinini);     }      public static void main(string[] args) {         system.out.println("changing");          string filename = "c:\\wallpapers\\wallpaper.jpg";          spi.instance.systemparametersinfo(                 new uint_ptr(spi.spi_setdeskwallpaper), new uint_ptr(0),                 filename, new uint_ptr(spi.spif_updateinifile                         | spi.spif_sendwininichange));         system.out.println("changed");     }  } 

by 'it not work' mean code runs wallpaper doesn't change.

turns out windows 7 doesn't setting jpeg images wallpaper. need convert image file bitmap first , set bmp image background.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -