import _winreg def get_desktop(): key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders') return _winreg.QueryValueEx(key, "Desktop")[0] |
import win32api,win32con def get_desktop(): key =win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders',0,win32con.KEY_READ) return win32api.RegQueryValueEx(key,'Desktop')[0] |
from win32com.shell import shell, shellcon def GetDesktopPath(): ilist =shell.SHGetSpecialFolderLocation(0, shellcon.CSIDL_DESKTOP) return shell.SHGetPathFromIDList(ilist) |
import os def GetDesktopPath(): return os.path.join(os.path.expanduser("~"), 'Desktop') |
import socket, os def GetDesktopPath() hostname = socket.gethostname() #socket.getfqdn(socket.gethostname()) basepath = os.path.join("C:\Users\",hostname ) return os.path.join(basepath, 'Desktop') |
|