Bonjour
je tente de récupérer mon adresse MAC par le code suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Public Function GetMACAddress() As String
Dim tmp As String
Dim pASTAT As Long
Dim NCB As NET_CONTROL_BLOCK
Dim AST As ASTAT
 
NCB.ncb_command = NCBRESET
Call Netbios(NCB)
 
NCB.ncb_callname = "* "
NCB.ncb_command = NCBASTAT
 
NCB.ncb_lana_num = 0
NCB.ncb_length = Len(AST)
pASTAT = HeapAlloc(GetProcessHeap(), _
HEAP_GENERATE_EXCEPTIONS Or _
HEAP_ZERO_MEMORY, _
NCB.ncb_length)
If pASTAT = 0 Then
Debug.Print "memory allocation failed!"
Exit Function
End If
NCB.ncb_buffer = pASTAT
Call Netbios(NCB)
CopyMemory AST, NCB.ncb_buffer, Len(AST)
tmp = Right$("00" & Hex(AST.adapt.adapter_address(0)), 2) & "." & _
Right$("00" & Hex(AST.adapt.adapter_address(1)), 2) & "." & _
Right$("00" & Hex(AST.adapt.adapter_address(2)), 2) & "." & _
Right$("00" & Hex(AST.adapt.adapter_address(3)), 2) & "." & _
Right$("00" & Hex(AST.adapt.adapter_address(4)), 2) & "." & _
Right$("00" & Hex(AST.adapt.adapter_address(5)), 2)
HeapFree GetProcessHeap(), 0, pASTAT
GetMACAddress = tmp
End Function
... le probleme est que la variable tmp ne renvoie que des "0" et la fonction AST.adapt.adapter_address() aussi .... qqun peut il m'aider à résoudre le pb SVP ?