你的位置:首页 > ASP.net教程

[ASP.net教程]C#循环注册表下的子键


public static bool IsAisino()
{
bool IsAisino = false;
//获取注册表路径
RegeditKey regeditKey = TaxSoftwareBaseInfo.GetRealyTrueRegeditPath(WindowsInfo.GetWindowsVersion());
RegistryKey regSubKey = null;
//获取驱动路径
regSubKey = regeditKey.Registry.OpenSubKey(@"System\CurrentControlSet\Control\Print\Printers\", false);
string[] rk = regSubKey.GetSubKeyNames();
foreach (var item in rk)
{

}

}

 

 

/// <summary>
/// 获取当前计算机系统版本
/// </summary>
/// <returns></returns>
public static WindowsVersion GetWindowsVersion()
{
int version = Environment.OSVersion.Version.Major;
string os = String.Concat(Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion").GetValue("ProductName").ToString());//, " ", Environment.OSVersion.ServicePack
if (os.Contains("7"))
{
if(GetSystemType()==64)
return WindowsVersion.Windows7_64Bit;
else
return WindowsVersion.Windows7_32Bit;
}
if (os.Contains("8"))
{
if (GetSystemType() == 64)
return WindowsVersion.Windows8_64Bit;
else
return WindowsVersion.Windows8_32Bit;
}

if (os.Contains("XP") && os.Contains("xp"))
{
if (GetSystemType() == 64)
return WindowsVersion.WindowsXP;
else
return WindowsVersion.WindowsXP;
}

int banben = GetSystemType();
throw new Exception("无法获取系统版本");
}