Where is the wallpaper registry key in Windows 8?

I am working on a tool that should get the current path of the user's wallpaper.

On Windows 7, I can get this by reading

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\General\WallpaperSource .

In my installation of Windows 8, this key always matters

C:\Users\Peter\AppData\Roaming\Microsoft\Windows Photo Viewer\Windows Photo Viewer Wallpaper.jpg

which is not even the two that are currently installed.

Is there any other key that I can rely on?

+7
source share
5 answers

The key you mention is not correct. It sounds to me that you placed the image as your desktop background from Internet Explorer, and this key was open to register it.

The correct key to get the desktop wallpaper: Confirmed: XP, CE, Vista, 7, 8

 HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper 

Details:

  • Primary Key: HKEY_CURRENT_USER
  • Turnkey: Control Panel \ Desktop
  • Value: WallPaper
  • Value Type: REG_SZ
  • Value data: full path for the image used as the desktop background.

In addition, under HKEY_CURRENT_USER\Control Panel\Desktop\ you will find other options related to both for applying different styles: Center, Tile and Stretch.

 HKEY_CURRENT_USER\Control Panel\Desktop\WallpaperStyle HKEY_CURRENT_USER\Control Panel\Desktop\TileWallpaper 

To apply styles, use the following guide:

  • Center

     WallpaperStyle = 0 TileWallpaper = 0 
  • Tile

     WallpaperStyle = 0 TileWallpaper = 1 
  • Stretch

     WallpaperStyle = 2 TileWallpaper = 0 
+6
source

You better call SystemParametersInfo with the parameter SPI_SETDESKWALLPAPER to set the desktop wallpaper. As far as I can tell, the registry key that you use is undocumented and thus may be changed at any time without warning.

See this question for an example of how to call SystemParametersInfo using SPI_SETDESKWALLPAPER.

+11
source

Based on the code available at pinvoke.net , the correct way to get the current wallpaper for your desktop wallpaper is to use SystemParametersInfo . An example of this is as follows:

 using System; using System.Runtime.InteropServices; namespace WallpaperPathRetrieval { class Program { [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern Int32 SystemParametersInfo(UInt32 action, UInt32 uParam, string vParam, UInt32 winIni); private static readonly UInt32 SPI_GETDESKWALLPAPER = 0x73; private static uint MAX_PATH = 260; static void Main(string[] args) { string wallpaper = new string('\0', (int)MAX_PATH); SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, wallpaper, 0); wallpaper = wallpaper.Substring(0, wallpaper.IndexOf('\0')); } } } 
+10
source

The registry is certainly not a good option. I will mix the collection of images for my desktop.

 Windows 8 RTM KEY: HKEY_CURRENT_USER\Control Panel\Desktop VALUE: C:\Users\Thomas\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper 

Code set to get the path using SystemParametersInfo returns the same value.

0
source

It is stored in a value named TranscodedImageCache (REG_BINARY). Here is a VBScript that reads / converts to plain text and prints the value.

How to determine the current file name of a file and path in Windows 8 - Winhelponline Blog

0
source

All Articles