Python win32con 模块,SPI_SETDESKWALLPAPER 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用win32con.SPI_SETDESKWALLPAPER

项目:pywallpaper    作者:AielloChan    | 项目源码 | 文件源码
def SetWallpaper(imagePath, fillType='fill'):
    tile = "0"
    if fillType == "tile":
        fillType = "center"
        tile = "1"
    fillDict = {
        "fill": "10",
        "fit": "6",
        "Stretch": "2",
        "center": "0",
        "span": "22"
    }
    style = fillDict[fillType]
    key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,
                                r"Control Panel\Desktop", 0,
                                win32con.KEY_SET_VALUE)
    win32api.RegSetValueEx(key, "WallpaperStyle", 0, win32con.REG_SZ, style)
    win32api.RegSetValueEx(key, "TileWallpaper", 0, win32con.REG_SZ, tile)
    win32gui.SystemParametersInfo(
        win32con.SPI_SETDESKWALLPAPER, imagePath, 1 + 2)

# main script
项目:bing-wallpaper    作者:guptarohit    | 项目源码 | 文件源码
def setWallPaperFromBmp(bmp):
    key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER, 'Control Panel\\Desktop', 0, win32con.KEY_SET_VALUE)
    win32api.RegSetValueEx(key, 'WallpaperStyle', 0, win32con.REG_SZ,'0')
    win32api.RegSetValueEx(key, 'TileWallpaper', 0, win32con.REG_SZ, '0')
    win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, bmp, 1+2)
项目:bing    作者:thatnight    | 项目源码 | 文件源码
def update_img(file_name):
    dir_name = os.path.abspath('.')
    print(dir_name)
    img_path = os.path.join(dir_name, file_name)
    print(img_path)
    win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, img_path, 1 + 2)


# delete picture per month
项目:Daily-code    作者:rui7157    | 项目源码 | 文件源码
def setWallpaper(self,fontsize=22,verticalspacing=26,leftmargin=800):   
        if self.__setimage(fontsize,verticalspacing,leftmargin)=="FilePathError":
            return "FilePathError"
        k = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,"Control Panel\\Desktop",0,win32con.KEY_SET_VALUE)  
        win32api.RegSetValueEx(k, "WallpaperStyle", 0, win32con.REG_SZ, "2")  
        win32api.RegSetValueEx(k, "TileWallpaper", 0, win32con.REG_SZ, "0")  
        win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, self.wallpaperpath, 1+2)