c#注册表操作全解

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Management;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Threading;

namespace util
{
   public class 注册表数据
    {
       public static void setRegistry(String[] args)  //setRegistry("SOFTWARE","Microsoft","Internet Explorer","Main","FeatureControl",);
       {
           RegistryKey zhuce1 = Registry.LocalMachine;
           for (int i = 0; i < args.Length - 2;i++ )
           {
               zhuce1 = zhuce1.OpenSubKey(args[i], true);
           }
           zhuce1.SetValue(args[args.Length - 2], args[args.Length - 1]);
       }

       public static List<string> 软件列表信息(int 选择)
       {
            List<string> 返回列表 = new List<string>();
           RegistryKey liebiao = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true);
           if (liebiao != null)
           {
               foreach (String ruanjian in liebiao.GetSubKeyNames())
               {
                   RegistryKey ruanjian2 = liebiao.OpenSubKey(ruanjian, false);
                   if (ruanjian2 != null)
                   {
                       string softwarename = ruanjian2.GetValue("DisplayName", "").ToString();
                       string quanlujing = ruanjian2.GetValue("DisplayIcon", "").ToString();
                       if (!string.IsNullOrEmpty(quanlujing))
                       {
                           if (选择 == 1)
                               返回列表.Add(softwarename);
                           if (选择 == 2)
                               返回列表.Add(quanlujing);
                       }
                   }
               }
           }
           return 返回列表;
       }
       public static int cpu频率()
       {
           RegistryKey cpu频率1 = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0");
           object cpu频率2 = cpu频率1.GetValue("~MHz");
           return (int)cpu频率2;
       }
       public static string cpu名称()
       {
           RegistryKey cpu名称1 = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0");
           object cpu名称2 = cpu名称1.GetValue("ProcessorNameString");
          return  (string)cpu名称2;
       }
    }
    
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

腾讯AI架构师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值