PCのホスト名を取得するには
System.Net.DnsクラスのGetHostName関数を使います。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Net; // これが必要 namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(Dns.GetHostName()); } } }
コメントを残す