Posted by: Christian Wimmer in: Common
In Windows XP there is a simple way to obtain the image you can see on the logon desktop right next to the username. All images are located in one folder and named after the user’s name.
“C:\Dokumente und Einstellungen\All Users\Anwendungsdaten\Microsoft\User Account Pictures\<username>.bmp”
So far so good. The bad message is :
This way does not work in Windows Vista anymore.
So where is it? The image can be found in “C:\Users\UserAsAdmin\Contacts\<user>.contact”. The format is a XML syntax. However at the moment I do not know how to retrieve the image….
You can find the user’s image here:
This file is created by the Windows Address Book Editor (wab.exe) and may not exist in the case that the user has never called the WAB editor.
So where is it in then? Look here:
This file is only available in Windows Vista and contains the user’s contact profile and her additionally contacts. The content is embedded into a XML structure. So you need to use either a XML parser, the obsolete Windows Address Book API (WAB) or the new Windows Contact API (WC).
Be aware that you cannot get a foreign user’s picture if “UserTile.png” does not exist. Neither WAB nor WC allow to load another contact file if you do not know the user’s contact GUID. Every user has a contact ID (GUID). It is saved into the contact file. However there is no secure way to distinguish between a user and his friends which are also stored in the same way. The only way to get the primary user contact GUID is to open the following registry key:
The standard value of this key defines a string that contains the user’s contact GUID and a path to the user’s contact file:
This string can be used as a parameter for IContactManager.Load.
If you do not prefer a secure way because you have to get the image of a foreign user, you can just get the first photo in the Photocollection. I suppose that new contacts are aways added at the end of collection (Don’t blame me if not).
<c:Photo c:ElementID="…GUID…" c:Version="1" c:ModificationDate="2007-10-06T16:13:52Z">
<c:Value c:ContentType="image/jpg" c:Version="18" c:ModificationDate="2008-03-26T10:59:20Z">
….. picture data of second (friend?) user here …
…more xml here
Next time we will discuss how to use the Windows Contact COM API. Goto.
The User Profile section in MSDN reads about the user’s tile. Although, it talks about Windows 7 (section: User Profile Tiles in Windows 7) the second paragraph is also true for at least Windows Vista. It reads:
The user’s current tile is stored in the C:\Users\<username>\Local\Temp folder as <username>.bmp.
The image file appears in the user’s Temp folder:
- After the user completes the initial system set-up (OOBE)
- When the user first goes to the User Accounts Control Panel
- If the user goes to the Manage Accounts subpage of the User Accounts Control Panel, tiles for every user on the PC will be placed there
And it also tells us that the picture is not always available. Neither the current user’s picture nor any other user’s picture may be available.
In addition the user’s picture may not be up to date:
If User B updates his or her user tile, User A won’t pick it up until User A goes into the Manage Accounts subpage. So, if applications use User A’s Temp folder to get User B’s tile, those applications may get an out of date image file.