GetAdaptersInfo獲取MAC位址

2021-06-26 23:03:46 字數 693 閱讀 7548

**:

源**:

#include#include#include"iphlpapi.h"

#pragma comment(lib,"iphlpapi.lib")

int main(int argc,char*argv)

if((dwretval=getadaptersinfo(padapterinfo,&uloutbuflen))==no_error)

printf("adaptertype:%d\n",padapter->type);

printf("ipaddress:%s\n",padapter->ipaddresslist.ipaddress.string);

printf("ipmask:%s\n",padapter->ipaddresslist.ipmask.string);

}padapter=padapter->next;}}

else

return 0;

}

備註: "iphlpapi.h","iphlpapi.lib"可能找不到,這個庫在vc安裝目錄可能有,也可能沒有,如果沒有,可以安裝winddk,在winddk相應目錄能找到該標頭檔案和庫檔案,找到之後,將標頭檔案所在目錄加入到工程的additional include directories,將庫檔案所在目錄加入到工程的additional library path。

delphi 實現通過ip位址獲取mac位址

function sendarp ipaddr ulong temp dword ulmacaddr pointer ulmacaddrleng pointer dword stdcall external iphlpapi.dll name sendarp function getmacbyip ...

linux核心根據skb獲取目的mac位址

工作筆記工作筆記linux程式設計 直接通過skb裡面的資訊獲取mac,如下 1.struct ethhdr eth hdr struct ethhdr skb mac header skb 2.if skb mac header was set skb 3.注意 需要先通過skb mac head...

linux 下C實現獲取網絡卡IP和MAC位址

本文使用getifaddrs 函式獲取網絡卡的ip和mac位址。getifaddrs函式有個特點,就是獲取位址時以鍊錶方式返回,且每個鍊錶節點要麼是ip,要麼是mac,所以如果要將網絡卡的ip和mac位址同時返回的話,需要對對返回鍊錶進行查詢和重新組合。本文實現目的,在於以網絡卡名方式返回ip和ma...