I want to get the filepath of the user's profile picture in Windows using Python.
I've found the following approach in VB6:
Option Explicit
'KERNEL32
Private Declare Function GetVersion Lib "KERNEL32" () As Long
'SHELL32
Private Declare Function SHGetUserPicturePath Lib "SHELL32" Alias "#261" (ByVal pUserOrPicName As Long, ByVal sguppFlags As Long, ByVal pwszPicPath As Long, ByVal picPathLen As Long) As Long
Private Declare Function xp_SHGetUserPicturePath Lib "SHELL32" Alias "#233" (ByVal pUserOrPicName As Long, ByVal sguppFlags As Long, ByVal pwszPicPath As Long) As Long
Private Const SGUPP_CREATEPICTURESDIR = &H80000000
Public Function LoadUserTile() As IPictureDisp
Dim sPath As String
sPath = String$(256, vbNullChar)
Select Case (GetVersion() And &HFF)
Case 5
Call xp_SHGetUserPicturePath(0, SGUPP_CREATEPICTURESDIR, StrPtr(sPath))
Case 6
Call SHGetUserPicturePath(0, SGUPP_CREATEPICTURESDIR, StrPtr(sPath), 256)
End Select
sPath = Left$(sPath, InStr(1, sPath, vbNullChar) - 1)
Set LoadUserTile = LoadPicture(sPath)
End Function
But I don't know how to translate it to Python using ctypes, as the functions used are not documented by the MSDN. I've found this alternative resource, though.
I've also tried to access this folder:
%ProgramData%\Microsoft\User Account Pictures\Guest.bmp
%ProgramData%\Microsoft\User Account Pictures\User.bmp
But there are stored the default profile pictures, not the current ones.