<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Windows XP Theme detector</Title>
      <Shortcut>WindowsXPThemedetector</Shortcut>
      <Description>Windows XP Theme detector [C#]</Description>
      <Author>Zepho Zep</Author>
      <HelpUrl>/PreviewSnippet.aspx?SnippetID=ab0969c6-de89-4dac-9f7c-7a7a60523bbf</HelpUrl>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="csharp"><![CDATA[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;
            }
        }
    }
}]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>