using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;
namespace CodeXchange.Samples
{
public enum Theme
{
WindowsClassic,
XPBlue,
XPSilver,
XPOliveGreen
}
public class XPTheme
{
public static Theme GetCurrentTheme()
{
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(
@"Software\Microsoft\Windows\CurrentVersion\ThemeManager");
if (key != null)
{
if ("1" == (string)key.GetValue("ThemeActive"))
{
string s = (string)key.GetValue("ColorName");
if (s != null)
{
if (String.Compare(s, "NormalColor", true) == 0)
return Theme.XPBlue;
if (String.Compare(s, "HomeStead", true) == 0)
return Theme.XPOliveGreen;
if (String.Compare(s, "Metallic", true) == 0)
return Theme.XPSilver;
}
}
}
return Theme.WindowsClassic;
}
catch (Exception e)
{
return Theme.WindowsClassic;
}
}
}
}
|