网站首页
网站导航
Ctrl+D收藏
首 页
代码段
源码包
文档库
工具箱
代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
JS
】
将bing每日壁纸设置为win7桌面壁纸
作者:
kongkongyzt
/ 发布于
2013/9/2
/
652
import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; import java.io.DataInputStream; import java.io.File; import java.io.FileOutputStream; import java.net.URL; import java.util.HashMap; //import MyWallpaper.SPI; import com.sun.jna.Native; import com.sun.jna.platform.win32.WinDef.UINT_PTR; import com.sun.jna.win32.*; public class MyWallpaper { public static void main(String[] argc) throws ParserConfigurationException, SAXException, IOException { //getting the path of the bing jpg picture via analysis xml DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse("http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=8"); document.normalize(); String relativePath =document.getElementsByTagName("url").item(0).getTextContent(); String path ="http://www.bing.com/"+relativePath; //download the jpg file URL url = new URL(path); DataInputStream dis = new DataInputStream(url.openStream()); FileOutputStream fos = new FileOutputStream(new File("C:\\wallpaper.jpg")); byte[] buffer = new byte[1024]; int length; while((length=dis.read(buffer))>0) { fos.write(buffer,0,length); } dis.close(); fos.close(); //setting the localpath into wallpaper String localpath = "C:\\wallpaper.jpg"; SPI.INSTANCE.SystemParametersInfo( new UINT_PTR(SPI.SPI_SETDESKWALLPAPER), new UINT_PTR(0), localpath, 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 ); } }
评论列表
本站所提供的代码,版权归原作者所有,若有侵犯作者版权,请与我们联系,我们将立即删除或修改。谢谢!
本站所有代码发布及提供者。
试试其它关键字
同语言下
.
Jquery搜索框获取回车事件
.
H5页面添加倒计时,然后自动跳转
.
通过user-agent判断h5页面是在哪个手机App(QQ、微信
.
nginx 禁止未绑定的域名访问
.
JavaScript 获取按键,并屏蔽系统 Window 事件
.
H5之只允许微信浏览器打开,禁止从外部浏览器访问
.
微信打开网址添加在浏览器中打开提示的办法
.
实现JS复制、粘贴,Chrome/Firefox下可用
.
video视频播放,play()、pause()、duration时长、onen
.
HTML5实现MP3上传前的预览和播放时长的获取
可能有用的
.
Jquery搜索框获取回车事件
.
H5页面添加倒计时,然后自动跳转
.
通过user-agent判断h5页面是在哪个手机App(QQ、微信
.
nginx 禁止未绑定的域名访问
.
JavaScript 获取按键,并屏蔽系统 Window 事件
.
H5之只允许微信浏览器打开,禁止从外部浏览器访问
.
微信打开网址添加在浏览器中打开提示的办法
.
实现JS复制、粘贴,Chrome/Firefox下可用
.
video视频播放,play()、pause()、duration时长、onen
.
HTML5实现MP3上传前的预览和播放时长的获取
kongkongyzt
贡献的其它代码
(
1
)
.
将bing每日壁纸设置为win7桌面壁纸
地图
本站
我们
服务
版权
联系
回馈
博客