1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using Microsoft.VisualBasic.Devices; using System.Runtime.InteropServices;
namespace ModifyComputerName { public partial class Frm_Main : Form { public Frm_Main() { InitializeComponent(); }
[DllImport("kernel32.dll")] private static extern int SetComputerName(string ipComputerName);
private void Frm_Main_Load(object sender, EventArgs e) { Computer computer = new Computer(); textBox1.Text = computer.Name;
SetComputerName(textBox2.Text); } } }
|