private bool VisualStylesEnabled() { Type typeFromHandle = typeof(Application); PropertyInfo property = typeFromHandle.GetProperty("RenderWithVisualStyles"); bool result; if (property == null) { OperatingSystem oSVersion = Environment.OSVersion; if (oSVersion.Platform == PlatformID.Win32NT && ((oSVersion.Version.Major == 5 && oSVersion.Version.Minor >= 1) || oSVersion.Version.Major > 5)) { NativeMethods.DLLVersionInfo dLLVersionInfo = default(NativeMethods.DLLVersionInfo); dLLVersionInfo.cbSize = Marshal.SizeOf(typeof(NativeMethods.DLLVersionInfo)); if (NativeMethods.DllGetVersion(ref dLLVersionInfo) == 0) { result = (dLLVersionInfo.dwMajorVersion > 5 && NativeMethods.IsThemeActive() && NativeMethods.IsAppThemed()); return(result); } } result = false; } else { bool flag = (bool)property.GetValue(null, null); result = flag; } return(result); }
public static extern int DllGetVersion(ref NativeMethods.DLLVersionInfo version);