Sprache: C#
Mit diesem Code kann man Informationen über CPU und BIOS aus der Registry auslesen.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace SystemInfo
{
public class Hardware
{
public static class CPU
{
public const string RegPath = @"HKEY_LOCAL_MACHINEHARDWAREDESCRIPTIONSystemCentralProcessor";
public static string Get(string Key)
{
return (string)Registry.GetValue(RegPath + "\0", Key, "");
}
public static string Name
{
get
{
return (string)Registry.GetValue(RegPath + "\0", "ProcessorNameString", "");
}
}
public static string Identifier
{
get
{
return (string)Registry.GetValue(RegPath + "\0", "Identifier", "");
}
}
}
public static class BIOS
{
public const string RegPath = @"HKEY_LOCAL_MACHINEHARDWAREDESCRIPTIONSystemBIOS";
public static string Get(string Key)
{
return (string)Registry.GetValue(RegPath, Key, "");
}
public static Dictionary<string, string> Settings()
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
using (var SubKey = Registry.LocalMachine.OpenSubKey(RegPath.Split(new char[] { '\' }, 2)[1]))
{
foreach (string Name in SubKey.GetValueNames())
{
dictionary.Add(Name, SubKey.GetValue(Name, "").ToString());
}
}
return dictionary;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace SystemInfo
{
public class Hardware
{
public static class CPU
{
public const string RegPath = @"HKEY_LOCAL_MACHINEHARDWAREDESCRIPTIONSystemCentralProcessor";
public static string Get(string Key)
{
return (string)Registry.GetValue(RegPath + "\0", Key, "");
}
public static string Name
{
get
{
return (string)Registry.GetValue(RegPath + "\0", "ProcessorNameString", "");
}
}
public static string Identifier
{
get
{
return (string)Registry.GetValue(RegPath + "\0", "Identifier", "");
}
}
}
public static class BIOS
{
public const string RegPath = @"HKEY_LOCAL_MACHINEHARDWAREDESCRIPTIONSystemBIOS";
public static string Get(string Key)
{
return (string)Registry.GetValue(RegPath, Key, "");
}
public static Dictionary<string, string> Settings()
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
using (var SubKey = Registry.LocalMachine.OpenSubKey(RegPath.Split(new char[] { '\' }, 2)[1]))
{
foreach (string Name in SubKey.GetValueNames())
{
dictionary.Add(Name, SubKey.GetValue(Name, "").ToString());
}
}
return dictionary;
}
}
}
}
Alte URL:
/snippet/systeminformationen-aus-der-registry-lesen/1750