You solve this problem in the same way as it: first you will find documentation and, ideally, good example code in C ++, C # or VB, then you will find out how to use PyWin32 to create the same shell API or IKnownFolder COM calls from Python.
As the MSDN overview documentation on Known Folders shows, you can use the new SHGetKnownFolderPath shell instead of the old SHFolderPath or SHGetFolderPath , or you can use the full IKnownFolderManager through COM.
Unfortunately, I do not have a Windows machine in front of me, and downloading MSDN samples does not respond, so I have to guess a little. But it could be something like this:
from win32com.shell import shell, shellcon path = shell.SHGetKnownFolderPath(shellcon.FOLDERID_AccountPictures, 0,
If the shellcon does not have FOLDERID values, you will have to look for them on KNOWNFOLDERID and determine the constants you need.
If the shell does not have the SHGetKnownFolderPath function, you need to instantiate IKnownFolderManager and call GetFolderByName .
If the shell doesn't even have an IKnownFolderManager ... but a quick google shows it was added in build 218 , so that won't be a problem.
If you prefer to do this via ctypes than win32com , it will look something like this (again, unverified, because I do not have a Windows window, and the MSDN server is not working):
from ctypes import windll, wintypes from ctypes import * from uuid import UUID
abarnert
source share