اقوم بتصميم موقع بلغة Asp.net و احتاج الى كود يجلب لى ال Mac Address الخاص بال Client
و قد جربت عدة اكواد وجدتها فى منتدى الفريق و لكن للاسف دون جدوى فجميع الاكواد الموجودة
تؤدى الى نتيجة واحدة و هى جلب Mac Addess للسرفير الذى استضيف عليه موقعى و ليس جهاز العميل
و لقد ارفقت ملف به الاكواد التى جربتها حتى اننى جرب بعض اكواد الجافا سكربت و لكن حصلت على اخطاء ايضا
الاكواد التى قمت بتجربتها
الكود الاول
Public Function GetMACAddress() As String
Dim computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
Dim nics As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
Dim sMacAddress As [string] = String.Empty
For Each adapter As NetworkInterface In nics
If sMacAddress = [string].Empty Then
Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
sMacAddress = adapter.GetPhysicalAddress.ToString()
End If
Next
Return sMacAddress
End Function
الكود الثانى :-
Private Function ListerMACs() As String
Dim os As OperatingSystem = Environment.OSVersion
Dim pid As PlatformID = os.Platform
Dim computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
Dim nics As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
Dim HostDomain As [string] = ("Interface information for " + computerProperties.HostName & ".") + computerProperties.DomainName
Dim MACList As String = String.Empty
Dim s As [string]
For Each adapter As NetworkInterface In nics
s = String.Empty
Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
Dim address As PhysicalAddress = adapter.GetPhysicalAddress()
Dim bytes As Byte() = address.GetAddressBytes()
For i As Integer = 0 To bytes.Length - 1
s = s & bytes(i).ToString("X2")
If i <> bytes.Length - 1 Then
s = s & ":"
End If
Next
MACList += s & vbLf
Next
Return MACList
End Function