• 0

[C#] Get current wallpaper location?


Question

Is there a way to pull the location of the currently displayed wallpaper? I know how to change it, but how do I find out what's currently being displayed?

This is what I use to change it:

private void ChangeWall()
{
int nResult;
nResult = WinAPI.SystemParametersInfo(20, 0, m_originalWallLocation,  0x1 | 0x2 );
}

public class WinAPI
{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static  extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni);
}

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
Why not read the registry?

The filename should be in HKCU\control panel\desktop\windowmetrics\wallpaper and that should work 98 through XP

584758523[/snapback]

Just realized that right before you posted. :) It's actually here:

HKCU\Control Panel\Desktop\Wallpaper

Anyone know the best place to get started on how to access the registry in C#? I've never done it before.

Link to comment
Share on other sites

  • 0
Just realized that right before you posted. :) It's actually here:

HKCU\Control Panel\Desktop\Wallpaper

Anyone know the best place to get started on how to access the registry in C#? I've never done it before.

584758542[/snapback]

MSDN library has a ton of stuff on reading/writing to/from the registry. :p

Link to comment
Share on other sites

  • 0
MSDN library has a ton of stuff on reading/writing to/from the registry:p:p

584758739[/snapback]

For the curious:

using Microsoft.Win32;

private void GetCurrentWallpaper()
{
  RegistryKey theCurrentMachine = Registry.CurrentUser;
  RegistryKey theControlPanel = theCurrentMachine.OpenSubKey ("Control Panel");
  RegistryKey theDesktop = theControlPanel.OpenSubKey ("Desktop");
  txtTemplate.Text = Convert.ToString(theDesktop.GetValue("Wallpaper"));
}

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.