zoukankan      html  css  js  c++  java
  • c# winfrom 获取电脑PC号或者是电脑的SN号

            /// <summary>
            /// 获得pc号
            /// </summary>
            public static string GetPcsnString()
            {
                var pcsn = "";
                try
                {
                    var search = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
                    var mobos = search.Get();
                    foreach (var temp in mobos)
                    {
                        object serial = temp["SerialNumber"]; // ProcessorID if you use Win32_CPU
                        pcsn = serial.ToString();
                        Console.WriteLine(pcsn);
    
                        if
                        (
                            !string.IsNullOrEmpty(pcsn)
                            && pcsn != "To be filled by O.E.M" //没有找到
                            && !pcsn.Contains("O.E.M")
                            && !pcsn.Contains("OEM")
                            && !pcsn.Contains("Default")
                        )
                        {
                            break;
                        }
                        else
                        {
                            Console.WriteLine("默认值");
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("获取过程发生异常");
                    //Debug.WriteLine(e);
                    // 无法处理
                }
    
                return pcsn;
            } 
  • 相关阅读:
    things to analysis
    retrieve jenkins console output
    temp
    temp
    mysql on Mac OS
    Scala的几个小tips
    docker查看容器使用率
    JVM性能监控(jconsole和jvisualvm)
    线程死锁问题
    线程阻塞状态
  • 原文地址:https://www.cnblogs.com/yinmu/p/11078076.html
Copyright © 2011-2022 走看看