cs_olfafoufa
Messages postés16Date d'inscriptiondimanche 2 mai 2010StatutMembreDernière intervention11 mai 2012
-
1 mars 2012 à 12:26
cs_olfafoufa
Messages postés16Date d'inscriptiondimanche 2 mai 2010StatutMembreDernière intervention11 mai 2012
-
2 mars 2012 à 14:37
salut tous le monde,
j'essaie avec ce code
Imports Microsoft.VisualBasic.Devices
Public Class Form1
Dim Computer As String
Dim montexte As String
Dim IPConfig As Object
Dim wscript As Object
Private Property IPConfigSet As Object
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dwLen As Long
Dim strString As String
On Error Resume Next
IPConfigSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//" & Computer).ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")
If Err.Number <> 0 Then
montexte = " - non accessible -"
Else
For Each IPConfig In IPConfigSet
wscript.echo(" adresse MAC " & vbTab & " : " & IPConfig.MACAddress & vbCrLf & _
" adresse IP " & vbTab & " : " & IPConfig.IPAddress(0))
Next
TextBox1.Text = IPConfig.IPAddress(0)
TextBox2.Text = IPConfig.MACAddress
End If
End Sub
End Class
Imports Microsoft.VisualBasic.Devices
Module Module1
Private Const MAX_COMPUTERNAME_LENGTH As Long = 31
Dim montexte As String
Private Property IPConfigSet As Object
Private Property Computer As String
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
End Module
Mais le résultat de ce code me donne une adresse IP :192.168.116.1 différente de celle de ma carte réseau .
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 2 mars 2012 à 07:52
quand je parle de code non .Net, je t'invite a exploiter le
System.Net.NetworkInformation :
Imports System.Net.NetworkInformation
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each ni As NetworkInterface In NetworkInterface.GetAllNetworkInterfaces()
MessageBox.Show("Nom : " & ni.Name & Environment.NewLine & _
"IP : " & ni.GetIPProperties.UnicastAddresses(0).Address.ToString() & Environment.NewLine & _
"MAC : " & ni.GetPhysicalAddress.ToString())
Next
End Sub
End Class