Search code examples
.netwindowsdesktop-background

How to discover which image file is the current desktop background on Windows?


It is possible to discover it programatically? It will use the Windows Registry? I'll need to take a screenshot of it and compare with the files on disk? Is it possible to discover even in the desktop slideshow mode?


Solution

  • public string GetCurrentWallpaper()
    {
        using(var subKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Desktop\General", false))
        {
            return subKey.GetValue("WallpaperSource").ToString();
        }
    }