Changes a users picture that is displayed at logon and on the start menu.
Syntax
HRESULT WINAPI SHSetUserPicturePath (
LPWSTR pwszAcctName,
DWORD reserved,
LPCWSTR pwszPictureFile
)
Parameters
- pwszAcctName
- The name of the user to set the picture of
- reserved
- Reserved, must be 0.
- pwszPictureFile
- Path of the file containing the new user picture
Return Value
S_OK on success, S_FALSE if the picture to set is the current one, and other common COM errors on failure
Remarks
CoInitialize(NULL)/CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) must be called prior to calling this function.
The 'pwszPictureFile' disk file can be in any format consumable by GDI+
The function crops or scales the given file to dimensions of 126x126 and converts it to bmp format via a temporary file created with the name %tmp%\pwszAcctName.tmp.bmp.
On success, any callbacks registered under HKLM\Software\Microsoft\Windows\CurrentVersion\UserPictureChange (these values are clsid's that implement the documented IUserAccountChangeCallback inteface).
On XP this function can only be used to set the picture of the current user unless the caller is a member of the admin group or is the localsystem account.
If the "Apply the default logon picture to all users" policy is enabled (gpedit.msc->Computer Configuration->Administrative Templates->Control Panel->User Accounts) the function fails with HRESULT_FROM_WIN32(ERROR_ACCESS_DISABLED_BY_POLICY)
The file that contains the picture data is kept at %AllUserProfile%\Microsoft\User Account Pictures\%username%.dat and has the following format:
dword 1 dword 2 (3 if the original filename is present) dword 1 dword filesize - rounded to nearest 4 filedata - BMP format dword 0 dword extensionLenInbytes - rounded to nearest 4 extension - Unicode text - without dot - null terminated dword 2 dword originalFileNameLen - in bytes rounded to nearest 4 Original file name - unicode text - null terminatedThis function is also known as _SHSetUserPicturePath@12 and _SHSetUserPicturePathW@12.