Get user picture

后端 未结 2 1545
余生分开走
余生分开走 2021-02-06 12:47

OS: Win7x64 (2008,2008r2). Lang: Delphi Xe2.

\"enter

2条回答
  •  死守一世寂寞
    2021-02-06 13:00

    There is an undocumented function in shell32.dll. On Windows XP its ordinal is 233, on Windows Vista and 7 its ordinal is 261.

    Its function prototype (from Airesoft) is:

    HRESULT WINAPI SHGetUserPicturePath (
        LPCWSTR pwszPicOrUserName, 
        DWORD sguppFlags, 
        LPWSTR pwszPicPath, 
        UINT picPathLen 
    )
    

    You can use this function to retrieve the path where the user picture is stored. Just pass the user name as pwszPicOrUserName, the buffer where you want to store the path to the picture as pwszPicPath and the size of the buffer in chars as picPathLen. You can set sguppFlags to 0 or to any of the other flags posssible.

    There is also a undocumented function which you can use in order to set the user picture of a user. Its ordinal is 234 on Windows XP, 262 on Windows Vista and Windows 7.

    Its function prototype (from Airesoft) is:

    HRESULT WINAPI SHSetUserPicturePath ( 
        LPWSTR pwszAcctName, 
        DWORD reserved, 
        LPCWSTR pwszPictureFile 
    )
    

    Pass the name of the user whose picture should be changed as pwszAcctName and the path to the picture you want to set as pwszPictureFile. Set reserved to 0. You have to initialize COM prior to calling this function.

    According to Microsoft you should not rely on undocumented function because they can be removed or changed with any patch which is installed on Windows.

提交回复
热议问题