获取用户图片 [英] Get user picture

查看:67
本文介绍了获取用户图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

  1. 如何接收图像用户帐户图片"的完整路径(和文件名)?
  2. 如何设置新图片?

有关delphi plz的示例.

Example on delphi plz.

需要:... function GetCurrentUserPicture:string;

Need: ...function GetCurrentUserPicture:string;

... function GetUserPicture(UserName:String):string;

...function GetUserPicture(UserName:String):string;

... function SetUserNewPicture(UserName,ImageFileName:String):bool;

...function SetUserNewPicture(UserName, ImageFileName:String):bool;

推荐答案

shell32.dll中有未记录的函数.在Windows XP上,其序号为233,在Windows Vista和7上,其序号为261.

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

其功能原型(来自Airesoft的 )是:

Its function prototype (from Airesoft) is:

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

您可以使用此功能来检索存储用户图片的路径.只需将用户名作为pwszPicOrUserName传递,要将图片的路径存储在其中的缓冲区作为pwszPicPath传递,将缓冲区的大小作为char传递给picPathLen.您可以将sguppFlags设置为0或任何其他标志.

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.

还有一个未公开的功能,可以用来设置用户的用户图片.在Windows XP中,其序号为234,在Windows Vista和Windows 7中,其序号为262.

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.

其功能原型(来自Airesoft的 )是:

Its function prototype (from Airesoft) is:

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

将要更改其图片的用户的名称传递为pwszAcctName,并将要设置为图片的路径传递为pwszPictureFile.设置为0保留.您必须在调用此函数之前初始化COM.

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.

根据Microsoft,您不应依赖未记录的功能,因为可以使用Windows上安装的任何修补程序将其删除或更改.

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.

这篇关于获取用户图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆