0

This is what I have found on stackoverflow. I am looking for a java class to change the windows wallpaper for me in windows 7.

public class changewallpaper {    
    public static void main(String[] args) {  
        //supply your own path instead of using this one 
        String path = "C:\\Users\\d1j5\\Pictures\\asgardrealmofthegods.jpg";  
        SPI.INSTANCE.SystemParametersInfo(     
                new UINT_PTR(SPI.SPI_SETDESKWALLPAPER),    
                new UINT_PTR(0),      
                path,          
                new UINT_PTR(SPI.SPIF_UPDATEINIFILE | SPI.SPIF_SENDWININICHANGE)); 
        }     public interface SPI extends StdCallLibrary {   
            //from MSDN article   
            long SPI_SETDESKWALLPAPER = 20;    
            long SPIF_UPDATEINIFILE = 0x01;   
            long SPIF_SENDWININICHANGE = 0x02;    
            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 
                            );   
                    }

    }

source for the code from stackoverflow

Community
  • 1
  • 1
jerhynsoen
  • 205
  • 1
  • 7
  • 20

1 Answers1

0

Assuming the code you've posted is exactly what you're trying to use... you've not included the body of the SPI interface. It's a shot in the dark considering you didn't tell us what error eclipse is throwing. If you want more specific help, you'll need to be more specific than saying some parts of your code are "red." That does not help us.

Copy the full code from the stackoverflow link you've posted and it ought to work.

Also, while unrelated to your problem, your class name should be changed to be consistent with the Java standards. See http://www.oracle.com/technetwork/java/codeconv-138413.html

Alex Lynch
  • 951
  • 5
  • 11
  • lol so its a friday, i did not copy all of the code. however it does not change my wallpaper. it works now... thanks! – jerhynsoen Jul 06 '12 at 22:31