我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用win32con.KEY_SET_VALUE。
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
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)
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)
def SetItemsCurrentValue(self, item, valueName, value): # ** Assumes already checked is a string. hkey = win32api.RegOpenKey(item.keyRoot, item.keyName , 0, win32con.KEY_SET_VALUE) try: win32api.RegSetValueEx(hkey, valueName, 0, win32con.REG_SZ, value) finally: win32api.RegCloseKey(hkey)