写的一个换桌面背景的工具,原来以为只本机的精简系统不行,后来发现所有机子都一样,重启后桌面背景会变成纯兰色的而非关机前设置的桌面壁纸
http://www.autoitx.com/thread-27559-1-1.html
#include <GDIPlus.au3>
#include <Array.au3>
Local $arry[1]
Local $count=0
Local $dest="C:\WINDOWS\WallPaper\"
;Global Const $SPI_SETDESKWALLPAPER = 0x0014
;Global Const $SPIF_UPDATEINIFILE = 0x01
;Global Const $SPIF_SENDCHANGE = 0x01
$search=FileFindFirstFile("C:\WINDOWS\WallPaper\"&"*.*")
while 1
$file=FileFindNextFile($search)
if @error then ExitLoop
_ArrayAdd($arry,$file)
$count=$count+1
WEnd ;循环目录中的所有文件
$rnd=Random(1,$count,1) ; 产生随机数
$wpaper=$arry[$rnd] ;随机图片
_GDIPlus_Startup ()
;初始化gdi
$hImage = _GDIPlus_ImageLoadFromFile ($dest&$wpaper)
;选择文件,保存句柄到$hImage
$sCLSID = _GDIPlus_EncodersGetCLSID ("BMP")
;理解成要保存的格式??
$tData = DllStructCreate("int Data")
;创建一个类似C++的数据结构
DllStructSetData($tData, "Data", $GDIP_EVTTRANSFORMROTATE90)
$tParams = _GDIPlus_ParamInit (1)
_GDIPlus_ParamAdd ($tParams, $GDIP_EPGTRANSFORMATION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Data"))
_GDIPlus_ImageSaveToFileEx ($hImage, "Wallpaper1.bmp", $sCLSID, DllStructGetPtr($tParams))
;保存文件,并命名为wallpaper1.bmp
_GDIPlus_ShutDown ()
;FileCopy("D:\Program Files\AutoIt3\work\Wallpaper1.bmp","C:\Documents and Settings\JOHn\Local Settings\Application Data\Microsoft\Wallpaper1.bmp",1)
dllcall("user32","int","SystemParametersInfo","int",20,"int",1,"str","Wallpaper1.bmp","int",1)
;dllcall("user32","int","SystemParametersInfo","int",$SPI_SETDESKWALLPAPER,"int",1,"str","Wallpaper1.bmp","int",BitOR($SPIF_UPDATEINIFILE,$SPIF_SENDCHANGE))
|