Getadaptersinof get LAN information for local connection, exclude wireless network card and virtual network card

Source: Internet
Author: User

/* Only to obtain the local connection network card information, do not obtain the wireless network card and the virtual network card information, to obtain the wireless card information, need toif(Strstr (Padapter->description,"PCI") >0&& padapter->type==mib_if_type_ethernet) changed toif(Strstr (padapter->type== in), to obtain information about the virtual network card, you need toif(Strstr (Padapter->description,"PCI") >0&& padapter->type==mib_if_type_ethernet) changed toif(padapter->type==mib_if_type_ethernet)*/#include "stdafx.h"#include <atlbase.h>#include <atlconv.h>#include "iphlpapi.h"#pragma comment (lib, "Iphlpapi.lib")intMain () {Pip_adapter_info padapterinfo=null; Pip_adapter_info Padapter=null;dword dwretval=0;p adapterinfo= (ip_adapter_info*)malloc (sizeof (ip_adapter_info)); ULONG uloutbuflen=sizeof (Ip_adapter_info);if(GetAdaptersInfo (Padapterinfo,&uloutbuflen)!=error_success) {GlobalFree (Padapterinfo);p adapterinfo= (ip_adapter_info*)malloc (Uloutbuflen);}if((Dwretval=getadaptersinfo (Padapterinfo,&uloutbuflen)) ==no_error) {padapter=padapterinfo; while(Padapter) {if(Strstr (Padapter->description,"PCI") >0&& padapter->type==mib_if_type_ethernet) {printf("______________________________________\n");printf("Name:%s\ n", padapter->adaptername);printf("Desc:%s\ n", padapter->description); for(UINT i=0; i<padapter->addresslength;i++) {printf("%02x%c", padapter->address[i],i==padapter->addresslength-1?' \ n ':'-');}printf("Type:%d\ n", Padapter->type);printf("Address:%s\ n", padapter->ipaddresslist.ipaddress.string);printf("Mask:%s\ n", padapter->ipaddresslist.ipmask.string);printf("Gateway:%s\ n", padapter->gatewaylist.ipaddress.string);} Padapter=padapter->next;}}Elseprintf("Call to GetAdaptersInfo failed!\n");return 0;}

Getadaptersinof get LAN information for local connection, exclude wireless network card and virtual network card

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.