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

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

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

實(shí)踐過程

效果

代碼

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

    private void Form1_Load(object sender, EventArgs e)
    {
        label1.Text = getCpu() + GetDiskVolumeSerialNumber();//獲得24位Cpu和硬盤序列號
        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個字符組成新的字符生成機(jī)器碼
        {
            label1.Text += strid[rdid.Next(0, 24)];
        }
    }
    //取得設(shè)備硬盤的卷標(biā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的序列號
    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è)計器變量。
    /// </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è)計器生成的代碼

    /// <summary>
    /// 設(shè)計器支持所需的方法 - 不要
    /// 使用代碼編輯器修改此方法的內(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 = "使用硬盤序列號和CPU序列號生成機(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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

最新評論

佛冈县| 汤阴县| 如东县| 虞城县| 内乡县| 广灵县| 即墨市| 湟中县| 高青县| 潼南县| 远安县| 封丘县| 伊川县| 金秀| 长治县| 常宁市| 海兴县| 峡江县| 潼南县| 友谊县| 诏安县| 广宗县| 通化市| 玉门市| 康保县| 萍乡市| 庄河市| 曲水县| 玉门市| 礼泉县| 清河县| 沾益县| 南澳县| 昭通市| 农安县| 治县。| 青州市| 湛江市| 赤峰市| 蒙自县| 历史|