اليوم أنا سوف اظهر لكم كيف يمكنك الحصول على عنوان MAC أجهزة الكمبيوتر، local ip and outgoing ip
أولا إنشاء مشروع جديد
1. افتح Visual Studio أو Visual الأساسية.
2. إنشاء مشروع جديد شكل النوافذ وتسميته ما تريد.
الآن لإضافة عناصر التحكم.
Now to add the controls.
Add 3 textboxes, name the first outtext the second iptext and the last mactext.
add 4 buttons, name the first copyout the second copyip and the last copymac, you dont need to rename
the last its just to get all the information.
Set the text on the copy buttons to copy.
الآن قم بإضافة في الجزء العلوي من التعليمات البرمجية الخاصة بك.
then you add this below public class
كود:
Dim ip As New WebClient
Now add this so that when you click on the buttons you copy it
كود:
Private Sub CopyOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyOut.Click
Clipboard.SetText(OutText.Text)
End Sub
Private Sub CopyIp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyIp.Click
Clipboard.SetText(IPtext.Text)
End Sub
Private Sub CopyMac_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyMac.Click
Clipboard.SetText(MACText.Text)
End Sub
Now we will add the code that gets the mac address the outgoing ip and the local ip, add this to your code.
كود:
Private Sub getoutip()
كود:
'Get outgoing ip
Try
OutText.Text = ip.DownloadString("http://www.networksecuritytoolkit.org/nst/tools/ip.php/")
Catch ex As Exception
OutText.Text = "No connection"
End Try
End Sub
Private Sub obtip()
'MAC Address
For Each nic As System.Net.NetworkInformation.NetworkInterface In System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
MACText.Text = String.Format("{2}", nic.Description, Environment.NewLine, nic.GetPhysicalAddress())
Exit For
Next
كود:
'Get local ip
Dim host As String = System.Net.Dns.GetHostName()
Dim LocalHostaddress As String = System.Net.Dns.GetHostByName(host).AddressList(0).ToString()
IPtext.Text = LocalHostaddress
End Sub
What this does is that it, downloads your ip address from http://www.networksecuritytoolkit.org/nst/tools/ip.php/ so that we can see it in the textbox
and it finds the mac address and the local ip in the network.
now to the last button add this.
You now done and it should look something like this