我想查找驱动器 D 上的操作系统版本(例如:Window 7 Pro):无需深入研究D:\Windows\System32\license.rtf
System.Management命名空间中是否有一个类可以让我在指定的本地驱动器号上找到操作系统版本?
我想查找驱动器 D 上的操作系统版本(例如:Window 7 Pro):无需深入研究D:\Windows\System32\license.rtf
System.Management命名空间中是否有一个类可以让我在指定的本地驱动器号上找到操作系统版本?
//This will help you detect the version of the OS for NT based system, if ntoskrnl.exe doesnt exist its ME/95/98
var DriveLetter = "D"; //D drive.
var pathTontoskrnl = string.Format("{0}:\\{1}", DriveLetter, "\\Windows\System32\ntoskrnl.exe");
if (!File.Exists(pathTontoskrnl))
{
Console.WriteLine("Windows ME/95/98");
}
var versionInfo = FileVersionInfo.GetVersionInfo(pathTontoskrnl);
string version = versionInfo.ProductVersion;
if ( version.StartsWith("5.1") )
{
Console.WriteLine("XP");
}
//4.x: NT 4.x
//5.0: Win2k
//5.1: WinXP
//5.2: Win2003 or XP-x64
//6.0: WinVista
//6.1: Win7
//6.2; Win8
//6.3: Win8.1
//6.4: Win10 ??? (not sure)