获取网卡的真实物理地址
标签:物理地址
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 | #Include <Memory.au3> #include <WinAPIEx.au3> Global $NicID , $iMac ;获取网卡真实物理地址 ;$NicID 在注册表中可以查询 ,下面两个位置均可以找到 ;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\** 子项中的ServiceName值 ;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\** 子项中可以找到 NetCfgInstanceId $iMac = _GetAdapterMac($NicID) ConsoleWrite($iMac) Func _GetAdapterMac($NicID) Local $hDevice, $hBuffer, $pBuffer, $tMem, $iMac $hDevice = _WinAPI_CreateFileEx("\\.\" & $NicId, $OPEN_EXISTING, 0, 0, 3, 0, 0) $iLength = 6 $hBuffer = _MemGlobalAlloc($iLength) $pBuffer = _MemGlobalLock($hBuffer) $tMem = DllStructCreate( "byte[" & $iLength & "]", $pBuffer) DllStructSetData($tMem, 1, 0x01010101) _MemGlobalUnlock($hBuffer) _WinAPI_DeviceIoControl($hDevice, 0x170002, DllStructGetPtr($tMem), 4, DllStructGetPtr($tMem), $iLength) $iMac = DllStructGetData($tMem, 1) $iMac = StringTrimLeft($iMac, 2) $iMac = StringTrimRight(StringRegExpReplace($iMac, "(..)", "\1-"), 1) Return $iMac EndFunc |