资源简介
通过VC++编程实现获取网络适配器名、网络适配器描述、MAC地址、IP地址、掩码等本地信息的小程序

代码片段和文件信息
// GetIPConfig.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#pragma comment(lib“IPHLPAPI.lib“)
#include
#include
#include
int _tmain(int argc _TCHAR* argv[])
{
//指定获取到的网络信息结构体链表的指针
IP_ADAPTER_INFO *p*a;
//保存获取到的网络结构信息结构体链表的长度
ULONG outlen;
//返回调用编码
DWORD dwRetval;
//为info分配空间
p=(IP_ADAPTER_INFO *)malloc(sizeof(IP_ADAPTER_INFO));
outlen=sizeof(IP_ADAPTER_INFO);
if(GetAdaptersInfo(p&outlen)!=ERROR_SUCCESS)
{
free(p);
p=(IP_ADAPTER_INFO *)malloc(outlen);
}
if(GetAdaptersInfo(p&outlen)!=ERROR_SUCCESS)
{
printf(“error“);
}
a=p;
while(a)
{
printf(“网络适配器名:\t\t%s\n“a->AdapterName);
printf(“网络适配器描述:\t%s\n\n“a->Description);
printf(“MAC地址:\t\t“);
for(int i=0;iAddressLength;i++)
{
if(i==a->AddressLength-1)
{
printf(“%2X“a->Address[i]);
}
else
{
printf(“%2X-“a->Address[i]);
}
}
printf(“\nIP地址:\t\t%s\n“a->IpAddressList.IpAddress.String);
printf(“子网掩码:\t\t%s\n“a->IpAddressList.IpMask.String);
printf(“网关:\t\t\t%s\n“a->GatewayList.IpAddress.String);
if(a->DhcpEnabled)
{
printf(“启用DHCP:\t\t是\n“);
printf(“DHCP服务器:\t\t%s\n“a->DhcpServer.IpAddress.String);
printf(“****************************************************************************\n\n“);
}
else
{
printf(“启用DHCP:\t\t否\n“);
printf(“****************************************************************************\n\n“);
}
a=a->Next;
}
if(p)
free(p);
system(“pause“);
printf(“\n\n“);
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-04-19 22:32 获取本地网络信息\
目录 0 2017-04-19 22:46 获取本地网络信息\GetIPConfig\
目录 0 2017-04-19 22:32 获取本地网络信息\GetIPConfig\Debug\
文件 27648 2017-04-19 22:45 获取本地网络信息\GetIPConfig\Debug\GetIPConfig.exe
文件 406 2017-04-19 22:22 获取本地网络信息\GetIPConfig\Debug\GetIPConfig.exe.manifest
文件 342556 2017-04-19 22:45 获取本地网络信息\GetIPConfig\Debug\GetIPConfig.ilk
文件 601088 2017-04-19 22:45 获取本地网络信息\GetIPConfig\Debug\GetIPConfig.pdb
目录 0 2017-04-19 22:32 获取本地网络信息\GetIPConfig\GetIPConfig\
文件 28987392 2017-04-19 22:46 获取本地网络信息\GetIPConfig\GetIPConfig.sdf
文件 900 2017-04-19 21:37 获取本地网络信息\GetIPConfig\GetIPConfig.sln
文件 11776 2017-04-19 22:46 获取本地网络信息\GetIPConfig\GetIPConfig.suo
目录 0 2017-04-19 22:46 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\
文件 3138 2017-04-19 22:45 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\cl.command.1.tlog
文件 34862 2017-04-19 22:45 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\CL.read.1.tlog
文件 1918 2017-04-19 22:45 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\CL.write.1.tlog
文件 2 2017-04-19 22:04 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig.exe.em
文件 68 2017-04-19 22:04 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig.exe.em
文件 381 2017-04-19 22:45 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig.exe.intermediate.manifest
文件 82 2017-04-19 22:46 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig.lastbuildstate
文件 2884 2017-04-19 22:46 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig.log
文件 34031 2017-04-19 22:45 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig.obj
文件 1179648 2017-04-19 22:45 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig.pch
文件 707 2017-04-19 22:04 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig.vcxprojResolveAssemblyReference.cache
文件 0 2017-04-19 22:04 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig.write.1.tlog
文件 212 2017-04-19 22:04 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\GetIPConfig_manifest.rc
文件 3038 2017-04-19 22:45 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\li
文件 5986 2017-04-19 22:45 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\li
文件 1678 2017-04-19 22:45 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\li
文件 978 2017-04-19 22:46 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\mt.command.1.tlog
文件 666 2017-04-19 22:46 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\mt.read.1.tlog
文件 306 2017-04-19 22:46 获取本地网络信息\GetIPConfig\GetIPConfig\Debug\mt.write.1.tlog
............此处省略17个文件信息
相关资源
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
- VC++基于OpenGL模拟的一个3维空间模型
评论
共有 条评论