Page 1 sur 1
[R] Adresse Mac ?
Posté : jeu. 23 mai 2013 21:32
par Ks10
Bonsoir,
Je voudrais savoir si il était possible de récupérer l'adresse mac d'un pc ?
Si oui comment ?
Merci d'avance.
Re: [..] Adresse Mac ?
Posté : jeu. 23 mai 2013 21:39
par TT22
► Afficher le texte
Code : Tout sélectionner
If @IPAddress1 <> "" Then
Global $UserIP = @IPAddress1
ElseIf @IPAddress2 <> "" Then
Global $UserIP = @IPAddress2
ElseIf @IPAddress3 <> "" Then
Global $UserIP = @IPAddress3
ElseIf @IPAddress4 <> "" Then
Global $UserIP = @IPAddress4
EndIf
MsgBox(0, "Adresse mac", "Votre adresse Mac est "&_GetMACFromIP($UserIP)&".")
Func _GetMACFromIP ($sIP)
Local $MAC,$MACSize
Local $i,$s,$r,$iIP
;Create the struct
;{
; char data[6];
;}MAC
$MAC = DllStructCreate("byte[6]")
;Create a pointer to an int
; int *MACSize;
$MACSize = DllStructCreate("int")
;*MACSize = 6;
DllStructSetData($MACSize,1,6)
;call inet_addr($sIP)
$r = DllCall ("Ws2_32.dll", "int", "inet_addr", _
"str", $sIP)
$iIP = $r[0]
;Make the DllCall
$r = DllCall ("iphlpapi.dll", "int", "SendARP", _
"int", $iIP, _
"int", 0, _
"ptr", DllStructGetPtr($MAC), _
"ptr", DllStructGetPtr($MACSize))
;Format the MAC address into user readble format: 00:00:00:00:00:00
$s = ""
For $i = 0 To 5
If $i Then $s = $s & ":"
$s = $s & Hex(DllStructGetData($MAC,1,$i+1),2)
Next
;Must free the memory after it is used
$MAC = 0
$MACSize = 0
;Return the user readble MAC address
Return $s
EndFunc
Re: [..] Adresse Mac ?
Posté : jeu. 23 mai 2013 21:41
par Tlem
Re: [..] Adresse Mac ?
Posté : jeu. 23 mai 2013 22:30
par jguinch
Bonsoir.
J'allais proposer d'utiliser mon UDF qui aurait pu convenir... Mais là, TT22 a sortit un truc excellent !
Je garde la fonction sous le coude !
Re: [..] Adresse Mac ?
Posté : sam. 25 mai 2013 18:20
par Ks10
Merci ça fonctionne
