C# MAC Adresi Öğrenme "FormApplication"

Katılım
27 Ocak 2012
Mesajlar
14.310
Makaleler
34
Çözümler
41
Yer
İstanbul/Üsküdar
Daha fazla  
Cinsiyet
Erkek
Meslek
Active Directory - Security Uzmanı
Profil Kapağı
1522600635
Kütüphanemize eklememiz gereken satırlar ;
C#:
using System.Management;
using System.Net.NetworkInformation;

Çağrılan Fonksiyon;
C#:
public string MACAdresiAl()
        {
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            String sMacAddress = string.Empty;
            foreach (NetworkInterface adapter in nics)
            {
                if (sMacAddress == String.Empty) sMacAddress = adapter.GetPhysicalAddress().ToString();
                textBox1.Text = (sMacAddress);
            }
            return sMacAddress;
            
        }

Fonksiyonu Tetikleme;
C#:
private void button1_Click(object sender, EventArgs e)
        {
            MACAdresiAl();
        }

Kodların Tamamı;
C#:
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.Management;
using System.Net.NetworkInformation;

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

        public string MACAdresiAl()
        {
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            String sMacAddress = string.Empty;
            foreach (NetworkInterface adapter in nics)
            {
                if (sMacAddress == String.Empty) sMacAddress = adapter.GetPhysicalAddress().ToString();
                textBox1.Text = (sMacAddress);
            }
            return sMacAddress;
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MACAdresiAl();
        }

        
    }
}

Programın Proje Dosyasını Buradan İndirebilirsiniz
 
Uyarı! Bu konu 6 yıl önce açıldı.
Muhtemelen daha fazla tartışma gerekli değildir ki bu durumda yeni bir konu başlatmayı öneririz. Eğer yine de cevabınızın gerekli olduğunu düşünüyorsanız buna rağmen cevap verebilirsiniz.

Yeni konular

Geri
Yukarı