8,756
社区成员




/// <summary>
/// 获取系统信息
/// </summary>
/// <returns></returns>
public string GetOSVersion()
{
//获取系统信息
OperatingSystem osinfo = Environment.OSVersion;
//获取操作系统ID
PlatformID platformID = osinfo.Platform;
//获取主版本号
int versionMajor = osinfo.Version.Major;
//获取副主版号
int versionManor = osinfo.Version.Minor;
if ((platformID == PlatformID.Win32NT) && (versionMajor == 5) && (versionManor == 1))
return "XP";
if ((platformID == PlatformID.Win32NT) && (versionMajor == 5) && (versionManor == 2))
return "2003";
if ((platformID == PlatformID.Win32NT) && (versionMajor == 6) && (versionManor == 0))
return "Vista";
if ((platformID == PlatformID.Win32NT) && (versionMajor == 6) && (versionManor == 1))
return "Win7";
if ((platformID == PlatformID.Win32NT) && (versionMajor == 6) && (versionManor == 2))
return "Win8";
return "QT";
}
<Application x:Class="Win7_AeroTheme.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/Aero.NormalColor.xaml"/>
</Application.Resources>
</Application>
private void ExtendAeroGlass(Window window)
{
try
{
// 为WPF程序获取窗口句柄
IntPtr mainWindowPtr = new WindowInteropHelper(window).Handle;
HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
mainWindowSrc.CompositionTarget.BackgroundColor = Colors.Transparent;
// 设置Margins
MARGINS margins = new MARGINS();
// 扩展Aero Glass
margins.cxLeftWidth = -1;
margins.cxRightWidth = -1;
margins.cyTopHeight = -1;
margins.cyBottomHeight = -1;
int hr = DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
if (hr < 0)
{
System.Windows.MessageBox.Show("DwmExtendFrameIntoClientArea Failed");
}
}
catch (DllNotFoundException)
{
System.Windows.Application.Current.MainWindow.Background = Brushes.White;
}
}
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int cxLeftWidth;
public int cxRightWidth;
public int cyTopHeight;
public int cyBottomHeight;
};
[DllImport("DwmApi.dll")]
public static extern int DwmExtendFrameIntoClientArea( IntPtr hwnd, ref MARGINS pMarInset);
这是xp下实现,现在差win8了,,,