#coding=utf-8 __author__ = 'Administrator' import pythoncom from win32com.shell import shell, shellcon g_desk = None def toGBK(s): return s.decode('utf-8').encode('gb2312') def getDeskComObject(): global g_desk if not g_desk: g_desk = pythoncom.CoCreateInstance(shell.CLSID_ActiveDesktop, \ None, pythoncom.CLSCTX_INPROC_SERVER, \ shell.IID_IActiveDesktop) return g_desk def setWallPaper(paper): desktop = getDeskComObject() if desktop: desktop.SetWallpaper(toGBK(paper), 0) desktop.ApplyChanges(shellcon.AD_APPLY_ALL) def addUrlLink(lnk): desktop = getDeskComObject() desktop.AddUrl(0, lnk, 0, 0) if __name__ == '__main__': paper = r'G:\meinv\长腿美女刘奕宁Lynn唯美私房照\16.jpg' setWallPaper(paper)