首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > C# > C#修改Windows电脑的计算机名

C#修改Windows电脑的计算机名

  • 资源大小:13.55 kB
  • 上传时间:2021-06-29
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: 其他

资 源 简 介

Visual C#修改计算机名,修改电脑名称为另一个自定义的新名称,代码较简单,这里不多做介绍了,运行界面如示例截图所示。以下为核心部分代码,先睹为快,完整源码项目请下载:   [DllImport("kernel32.dll")]   private static extern int SetComputerName(string ipComputerName);//重写API函数   private void Frm_Main_Load(object sender, EventArgs e)   {    Computer computer = new Computer();//创建计算机对象    textBox1.Text = computer.Name;//显示计算机名称   }   private void button1_Click(object sender, EventArgs e)   {    if (textBox2.Text == "")//判断计算机名称是否为空    {    MessageBox.Show("计算机名称不能为空!");    }    else    {    SetComputerName(textBox2.Text);//修改计算机名称    MessageBox.Show("计算机名称修改成功,请重新启动计算机使之生效!");    }   }

文 件 列 表

srcfans.com
ModifyComputerName
ModifyComputerName
ModifyComputerName
Frm_Main.cs
srcfans.com
VIP VIP
0.170599s