最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#實(shí)現(xiàn)獲取機(jī)器碼的示例詳解

 更新時(shí)間:2022年12月30日 09:00:19   作者:芝麻粒兒  
這篇文章主要為大家詳細(xì)介紹了如何利用C#實(shí)現(xiàn)獲取機(jī)器碼的功能,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下

實(shí)踐過(guò)程

效果

代碼

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        label1.Text = getCpu() + GetDiskVolumeSerialNumber();//獲得24位Cpu和硬盤序列號(hào)
        string[] strid = new string[24];
        for (int i = 0; i < 24; i++)//把字符賦給數(shù)組
        {
            strid[i] = label1.Text.Substring(i, 1);
        }
        label1.Text = "";
        Random rdid = new Random();
        for (int i = 0; i < 24; i++)//從數(shù)組隨機(jī)抽取24個(gè)字符組成新的字符生成機(jī)器碼
        {
            label1.Text += strid[rdid.Next(0, 24)];
        }
    }
    //取得設(shè)備硬盤的卷標(biāo)號(hào)
    public string GetDiskVolumeSerialNumber()
    {
        ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
        ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"d:\"");
        disk.Get();
        return disk.GetPropertyValue("VolumeSerialNumber").ToString();
    }
    //獲得CPU的序列號(hào)
    public string getCpu()
    {
        string strCpu = null;
        ManagementClass myCpu = new ManagementClass("win32_Processor");
        ManagementObjectCollection myCpuConnection = myCpu.GetInstances();
        foreach (ManagementObject myObject in myCpuConnection)
        {
            strCpu = myObject.Properties["Processorid"].Value.ToString();
            break;
        }
        return strCpu;
    }
}
partial class Form1
{
    /// <summary>
    /// 必需的設(shè)計(jì)器變量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的資源。
    /// </summary>
    /// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows 窗體設(shè)計(jì)器生成的代碼

    /// <summary>
    /// 設(shè)計(jì)器支持所需的方法 - 不要
    /// 使用代碼編輯器修改此方法的內(nèi)容。
    /// </summary>
    private void InitializeComponent()
    {
        this.label1 = new System.Windows.Forms.Label();
        this.label3 = new System.Windows.Forms.Label();
        this.label4 = new System.Windows.Forms.Label();
        this.SuspendLayout();
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.Font = new System.Drawing.Font("宋體", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        this.label1.Location = new System.Drawing.Point(87, 28);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(0, 16);
        this.label1.TabIndex = 6;
        // 
        // label3
        // 
        this.label3.AutoSize = true;
        this.label3.Font = new System.Drawing.Font("宋體", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
        this.label3.Location = new System.Drawing.Point(104, 65);
        this.label3.Name = "label3";
        this.label3.Size = new System.Drawing.Size(0, 16);
        this.label3.TabIndex = 7;
        // 
        // label4
        // 
        this.label4.AutoSize = true;
        this.label4.Location = new System.Drawing.Point(28, 32);
        this.label4.Name = "label4";
        this.label4.Size = new System.Drawing.Size(53, 12);
        this.label4.TabIndex = 8;
        this.label4.Text = "機(jī)器碼:";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.BackColor = System.Drawing.SystemColors.Control;
        this.ClientSize = new System.Drawing.Size(353, 75);
        this.Controls.Add(this.label4);
        this.Controls.Add(this.label3);
        this.Controls.Add(this.label1);
        this.MaximizeBox = false;
        this.MinimizeBox = false;
        this.Name = "Form1";
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "使用硬盤序列號(hào)和CPU序列號(hào)生成機(jī)器碼";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.Label label4;
}

到此這篇關(guān)于C#實(shí)現(xiàn)獲取機(jī)器碼的示例詳解的文章就介紹到這了,更多相關(guān)C#獲取機(jī)器碼內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • C#生成驗(yàn)證碼圖片的方法

    C#生成驗(yàn)證碼圖片的方法

    這篇文章主要為大家詳細(xì)介紹了C#生成驗(yàn)證碼圖片的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-10-10
  • C# Redis學(xué)習(xí)系列(一)Redis下載安裝使用

    C# Redis學(xué)習(xí)系列(一)Redis下載安裝使用

    這篇文章主要為大家分享了C# Redis學(xué)習(xí)系列教程第一篇, Redis下載、安裝、使用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • C#計(jì)算字符串哈希值(MD5、SHA)的方法小結(jié)

    C#計(jì)算字符串哈希值(MD5、SHA)的方法小結(jié)

    這篇文章主要介紹了C#計(jì)算字符串哈希值(MD5、SHA)的方法,以實(shí)例形式較為詳細(xì)的分析總結(jié)了C#計(jì)算字符串哈希值的各種常用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-08-08
  • C#中基于流的XML文件操作筆記

    C#中基于流的XML文件操作筆記

    這篇文章主要介紹了C#中基于流的XML文件操作筆記,本文主要是講解針對(duì)XmlReader和XmlWriters兩個(gè)XML讀寫類的使用,需要的朋友可以參考下
    2015-06-06
  • 基于WPF簡(jiǎn)單實(shí)現(xiàn)Meesage消息提醒

    基于WPF簡(jiǎn)單實(shí)現(xiàn)Meesage消息提醒

    這篇文章主要介紹了如何利用WPF簡(jiǎn)單實(shí)現(xiàn)Meesage消息提醒,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)或工作有一定幫助,需要的可以參考一下
    2023-07-07
  • 一起詳細(xì)聊聊C#中的Visitor模式

    一起詳細(xì)聊聊C#中的Visitor模式

    Visitor模式表示一個(gè)作用于某對(duì)象結(jié)構(gòu)中的各元素的操作,下面這篇文章主要給大家介紹了關(guān)于C#中Visitor模式的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-05-05
  • C# 通過(guò)反射獲取類型的字段值及給字段賦值的操作

    C# 通過(guò)反射獲取類型的字段值及給字段賦值的操作

    這篇文章主要介紹了C# 通過(guò)反射獲取類型的字段值及給字段賦值的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-01-01
  • C#中屬性和成員變量的區(qū)別說(shuō)明

    C#中屬性和成員變量的區(qū)別說(shuō)明

    本篇文章主要是對(duì)C#中屬性和成員變量的區(qū)別進(jìn)行了介紹說(shuō)明。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助
    2014-01-01
  • 在winform中實(shí)現(xiàn)雙向數(shù)據(jù)綁定的方法

    在winform中實(shí)現(xiàn)雙向數(shù)據(jù)綁定的方法

    雙向數(shù)據(jù)綁定是一種允許我們創(chuàng)建持久連接的技術(shù),使模型數(shù)據(jù)和用戶界面(UI)之間的交互能夠自動(dòng)同步,今天我想通過(guò)winform中DataGridView控件為例,介紹在winform中如何實(shí)現(xiàn)雙向數(shù)據(jù)綁定,需要的朋友可以參考下
    2024-03-03
  • C#檢查指定對(duì)象是否存在于ArrayList集合中的方法

    C#檢查指定對(duì)象是否存在于ArrayList集合中的方法

    這篇文章主要介紹了C#檢查指定對(duì)象是否存在于ArrayList集合中的方法,涉及C#中Contains方法的使用技巧,需要的朋友可以參考下
    2015-04-04

最新評(píng)論

东明县| 天峨县| 西充县| 平潭县| 永年县| 安溪县| 宝山区| 桂东县| 湘潭市| 儋州市| 咸阳市| 台东县| 井陉县| 邯郸市| 犍为县| 富民县| 云阳县| 宣汉县| 大连市| 河东区| 富川| 元朗区| 西乡县| 武定县| 忻城县| 鄂尔多斯市| 陆川县| 开封县| 工布江达县| 麦盖提县| 鄂托克前旗| 定襄县| 云龙县| 苏尼特右旗| 宁南县| 探索| 三原县| 故城县| 南川市| 凤庆县| 万年县|