Kaydol:
Kayıt Yorumları
(
Atom
)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.NetworkInformation;
namespace C_Sharp_Form_Ip_Adres_Mac_Adres_Ogrenme
{
public partial class Ip_Adres_Mac_Adres_Ogrenme_Form : Form
{
public Ip_Adres_Mac_Adres_Ogrenme_Form()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Burada ağ arayüzünü foreach ile dolaşarak bilgisayarın fiziksel
// mac adreslerini yazdırıyoruz
foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces())
{
var macAddress = networkInterface.GetPhysicalAddress().ToString();
if (macAddress != string.Empty)
{
listBox1.Items.Add("Mac Adres : " + macAddress);
}
}
// IP Adress sınıfında olusturduğumuz örneğimize DNS deki ip
// adreslerini alıyoruz ve bunları listemize yadırıyoruz
IPAddress[] ipHostAddress = Dns.GetHostAddresses(Dns.GetHostName());
for (int i = 0; i < ipHostAddress.Length; i++)
{
listBox1.Items.Add("Lokal IP Adres : " + ipHostAddress[i].ToString());
}
}
}
}
Hiç yorum yok :
Yorum Gönder