Sunday, December 19, 2010

Posted by SAMAJ SHEKHAR

1”

Get current desktop theme


Recently i answered to a question at StackOverflow , where user wanted to know which desktp theme is currently is set on his computer. I thought that it could be a good post so i am posting that code here too.

What it simply does is that it looks for the Currently set theme in the windows registry and returns it as a string.

The current theme is stored in the CurrentTheme string in

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes

Following is the code:

using Microsoft.Win32;

public string GetTheme()
{
  string RegistryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes";
  string theme;
  theme = (string) Registry.GetValue(RegistryKey, "CurrentTheme", string.Empty);
  theme = theme.Split('\\').Last().Split('.').First().ToString();
  return theme;
}

1 comment:

SAMAJ SHEKHAR said...

Please a have a look at http://stackoverflow.com/questions/4479421/get-windows-theme/4481640#4481640 for Place in which above can fail

Post a Comment