Get SystemVersionInfo with Interop
This commit is contained in:
1 parent
c46f8a754c
commit
0fe47b2925
6 files changed
+27
-8
No files matched your search
@@ -73,7 +73,6 @@ namespace HandyControlDemo
|
|||||||
UpdateSkin(GlobalData.Config.Skin);
|
UpdateSkin(GlobalData.Config.Skin);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHelper.Instance.SystemVersionInfo = CommonHelper.GetSystemVersionInfo();
|
|
||||||
ConfigHelper.Instance.SetWindowDefaultStyle();
|
ConfigHelper.Instance.SetWindowDefaultStyle();
|
||||||
ConfigHelper.Instance.SetNavigationWindowDefaultStyle();
|
ConfigHelper.Instance.SetNavigationWindowDefaultStyle();
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,18 @@ namespace HandyControl.Controls
|
|||||||
base.OnApplyTemplate();
|
base.OnApplyTemplate();
|
||||||
EnableBlur(this);
|
EnableBlur(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static SystemVersionInfo GetSystemVersionInfo()
|
||||||
|
{
|
||||||
|
var osv = new InteropValues.RTL_OSVERSIONINFOEX();
|
||||||
|
osv.dwOSVersionInfoSize = (uint)Marshal.SizeOf(osv);
|
||||||
|
InteropMethods.Gdip.RtlGetVersion(out osv);
|
||||||
|
return new SystemVersionInfo((int)osv.dwMajorVersion, (int)osv.dwMinorVersion, (int)osv.dwBuildNumber);
|
||||||
|
}
|
||||||
|
|
||||||
internal static void EnableBlur(Window window)
|
internal static void EnableBlur(Window window)
|
||||||
{
|
{
|
||||||
var versionInfo = ConfigHelper.Instance.SystemVersionInfo;
|
var versionInfo = GetSystemVersionInfo();
|
||||||
|
|
||||||
if (versionInfo < SystemVersionInfo.Windows10 ||
|
if (versionInfo < SystemVersionInfo.Windows10 ||
|
||||||
versionInfo >= SystemVersionInfo.Windows10_1903)
|
versionInfo >= SystemVersionInfo.Windows10_1903)
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
{
|
{
|
||||||
public class HandyControlConfig
|
public class HandyControlConfig
|
||||||
{
|
{
|
||||||
public SystemVersionInfo SystemVersionInfo { get; set; }
|
|
||||||
|
|
||||||
public string Lang { get; set; }
|
public string Lang { get; set; }
|
||||||
|
|
||||||
public int TimelineFrameRate { get; set; } = 60;
|
public int TimelineFrameRate { get; set; } = 60;
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ namespace HandyControl.Tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SystemVersionInfo SystemVersionInfo { get; set; }
|
|
||||||
|
|
||||||
public void SetLang(string lang)
|
public void SetLang(string lang)
|
||||||
{
|
{
|
||||||
LangProvider.Culture = new CultureInfo(lang);
|
LangProvider.Culture = new CultureInfo(lang);
|
||||||
@@ -48,7 +46,6 @@ namespace HandyControl.Tools
|
|||||||
|
|
||||||
public void SetConfig(HandyControlConfig config)
|
public void SetConfig(HandyControlConfig config)
|
||||||
{
|
{
|
||||||
SystemVersionInfo = config.SystemVersionInfo;
|
|
||||||
SetLang(config.Lang);
|
SetLang(config.Lang);
|
||||||
SetTimelineFrameRate(config.TimelineFrameRate);
|
SetTimelineFrameRate(config.TimelineFrameRate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -703,6 +703,10 @@ namespace HandyControl.Tools.Interop
|
|||||||
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||||
[ResourceExposure(ResourceScope.None)]
|
[ResourceExposure(ResourceScope.None)]
|
||||||
internal static extern int GdipSaveImageToStream(HandleRef image, InteropValues.IStream stream, ref Guid classId, HandleRef encoderParams);
|
internal static extern int GdipSaveImageToStream(HandleRef image, InteropValues.IStream stream, ref Guid classId, HandleRef encoderParams);
|
||||||
|
|
||||||
|
[DllImport(InteropValues.ExternDll.NTdll)]
|
||||||
|
internal static extern int RtlGetVersion(out InteropValues.RTL_OSVERSIONINFOEX lpVersionInformation);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,8 @@ namespace HandyControl.Tools.Interop
|
|||||||
GdiPlus = "gdiplus.dll",
|
GdiPlus = "gdiplus.dll",
|
||||||
Kernel32 = "kernel32.dll",
|
Kernel32 = "kernel32.dll",
|
||||||
Shell32 = "shell32.dll",
|
Shell32 = "shell32.dll",
|
||||||
MsImg = "msimg32.dll";
|
MsImg = "msimg32.dll",
|
||||||
|
NTdll = "ntdll.dll";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
|
internal delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
|
||||||
@@ -956,5 +957,17 @@ namespace HandyControl.Tools.Interop
|
|||||||
public RECT rc;
|
public RECT rc;
|
||||||
public int lParam;
|
public int lParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
internal struct RTL_OSVERSIONINFOEX
|
||||||
|
{
|
||||||
|
internal uint dwOSVersionInfoSize;
|
||||||
|
internal uint dwMajorVersion;
|
||||||
|
internal uint dwMinorVersion;
|
||||||
|
internal uint dwBuildNumber;
|
||||||
|
internal uint dwPlatformId;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||||
|
internal string szCSDVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user