zoukankan      html  css  js  c++  java
  • C#-获取CPUID

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;
    using System.IO;
    
    namespace T
    {
        class GetCpuid
        {
            public string Getid()
            {
                try
                {
                    string Str = InvokeCmd("@wmic cpu get processorId > c:\tmpp.txt");
                    StreamReader sr = new StreamReader(@"c:	mpp.txt", Encoding.Default);
                    string s, Id = "null";
                    int mk = 0;
                    while ((s = sr.ReadLine()) != null)
                    {
                        mk++;
                        if (mk == 2) Id = s;
                    }
                    sr.Close();
                    InvokeCmd("del  c:\tmpp.txt");
                    Id = Id.Trim();
                    return Id;
                }
                catch
                {
                    return "null";
                }
    
            }
    
            private  string InvokeCmd(string cmdArgs)
            {
                string Tstr = "";
                Process p = new Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.CreateNoWindow = true;
                p.Start();
    
                p.StandardInput.WriteLine(cmdArgs);
                p.StandardInput.WriteLine("exit");
                Tstr = p.StandardOutput.ReadToEnd();
                p.Close();
                return Tstr;
            }
        }
    }
    

  • 相关阅读:
    链表相加
    Unity 摄像机跟随
    整数反转
    两数和
    频繁项集挖掘思路
    有关于二进制的乘法计算(原码一位乘)
    JAVA面向对象(下)
    JAVAAPI
    JAVA面向对象()上)
    JAVA基础第一章
  • 原文地址:https://www.cnblogs.com/csnd/p/12062206.html
Copyright © 2011-2022 走看看