• 获取网卡信息


    #include <stdio.h>
    #include <windows.h>
    #include <stdlib.h>
    #include <malloc.h>
    #include "Iphlpapi.h"
    
    #pragma comment(lib,"IPHLPAPI.LIB")
    
    int main()
    {
        PIP_ADAPTER_INFO pAdapterInfo;
        PIP_ADAPTER_INFO pAdapter   = NULL;
        DWORD dwRetVal              =        0;
    
        pAdapterInfo = (IP_ADAPTER_INFO*)malloc(sizeof(PIP_ADAPTER_INFO));
        ULONG ulOutBufLen = sizeof(PIP_ADAPTER_INFO);
    
        if(GetAdaptersInfo(pAdapterInfo,&ulOutBufLen)==ERROR_BUFFER_OVERFLOW)
        {
            free(pAdapterInfo);
            pAdapterInfo = (IP_ADAPTER_INFO*)malloc(ulOutBufLen);
        }
        
        if((dwRetVal = GetAdaptersInfo(pAdapterInfo,&ulOutBufLen))==NO_ERROR)
        {
            pAdapter = pAdapterInfo;
    
            while(pAdapter)
            {
                printf("Adapter Name:\t%s\n",pAdapter->AdapterName);
                printf("Adapter Desc:\t%s\n",pAdapter->Description);
                printf("Adapter Addr:\t%2.2x-%2.2x-%2.2x-%2.2x-%2.2x-%2.2x",
                    pAdapter->Address[0],pAdapter->Address[1],pAdapter->Address[2],
                    pAdapter->Address[3],pAdapter->Address[4],pAdapter->Address[5]);
                printf("IP Address:\t%s\n",pAdapter->IpAddressList.IpAddress.String);
                printf("IP Mask:\t%s\n",pAdapter->IpAddressList.IpMask.String);
                printf("GateWay:\t%s\n",pAdapter->GatewayList.IpAddress.String);
                printf("**********************\n");
    
                if(pAdapter->DhcpEnabled)
                {
                    printf("DHCP Enabled : YES\n");
                    printf("\tDHCP Server:\t%s\n",pAdapter->DhcpServer.IpAddress.String);
                    printf("Lease Obtained:%ld\n",pAdapter->LeaseObtained);
                }
                else
                {
                    printf("DHCP Enabled : NO \n");
                }
    
    
                if(pAdapter->HaveWins)
                {
                    printf("Have Wins : YES");
                    printf("\tPrimary Wins Server :\t%s\n",pAdapter->PrimaryWinsServer.IpAddress.String);
                    printf("\tSecondary Wins Server : \t%s\n",pAdapter->SecondaryWinsServer.IpAddress.String);
                }
                else
                {
                    printf("Have Wins :NO\n");
                }
    
                pAdapter = pAdapter->Next;
            }
        }
        else
        {
            printf("Call to GetAdaptersInfo failed\n");
        }
        return 0;
    }

    ..

  • 相关阅读:
    编写SASS代码
    表单
    动画和变形
    图片多媒体
    基本概念
    弹性布局
    HTML和CSS概述
    页面的制作过程
    盒子定位体系
    css盒子
  • 原文地址:https://www.cnblogs.com/tk091/p/2752803.html
Copyright © 2020-2023  润新知