58 lines
1.7 KiB
C#
Raw Permalink Normal View History

2025-10-11 18:25:59 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace XiaoZhiSharp.Kernels
{
public enum OperatingSystemType
{
Windows = 0,
Linux = 1
}
public static class OperatingSystem
{
public static OperatingSystemType GetOperatingSystemType()
{
//if (Environment.OSVersion.Platform != PlatformID.Win32S ||
// Environment.OSVersion.Platform != PlatformID.Win32Windows ||
// Environment.OSVersion.Platform != PlatformID.WinCE ||
// Environment.OSVersion.Platform != PlatformID.Win32NT)
// return;
OperatingSystemType type = OperatingSystemType.Windows;
var os = Environment.OSVersion;
var platform = os.Platform;
string osType = platform.ToString();
if (!(osType == "Win32NT"))
{
if (osType == "Unix")
{
type = OperatingSystemType.Linux;
}
}
else
{
type = OperatingSystemType.Windows;
/*
var sysStr = string.Empty;
var version = os.Version;
if (version.Major == 6 && version.Minor == 1)
{
sysStr = "Windows 7";
}
else if (version.Major == 10)
{
sysStr = "Windows 10";
}
else
{
sysStr = "Unknown";
}*/
}
return type;
}
}
}