| 首页 | 学习 | 计算机 | 小说 | 动漫 | 论文 | 军事 | 科技 | 教育 | 哲学 | 历史 | 英语 | 笑话 | 
您现在的位置: 【书斋】 >> 计算机 >> 程序编程 >> 计算机正文 用户登录 新用户注册
取得网卡的一些信息的代码           ★★
取得网卡的一些信息的代码
////////////////////////////////////////////////////////////////
//运行本程序需要安装Microsoft Platform SDK .这个可以去MS下载
//http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
//作者:安静
//mail: aweiken@163.com
//10:56 2002-1-31 start
//14:44 2002-2-2 fix some bug.
//////////////////////////////////////////////////////////////////

#include "stdafx.h"

#include
#include
#include "Iphlpapi.h"

using namespace std;


PIP_ADAPTER_INFO pinfo=NULL;
unsigned long len=0;

CString macaddress;
CString description;
CString type;
CString subnet;
CString IpAddress;
CString gateway;
CString PrimaryWinsServer;
CString dhcp;

void GetInfo();
void ParseData();
void OutPut(CString str);

void main()
{


cout<<"------------------------网卡信息检测---------------------\n";
GetInfo();

}

void GetInfo()
{
if (pinfo!=NULL)
delete (pinfo);
unsigned long nError;
nError = GetAdaptersInfo(pinfo,&len); //1??üoˉêy
if (nError==0)
{
ParseData();
}
if (nError==ERROR_NO_DATA)
{
OutPut("没有网络设备信息");
}
if (nError==ERROR_NOT_SUPPORTED)
{
OutPut("GetAdaptersInfo 不支持本系统");
}
if (nError==ERROR_BUFFER_OVERFLOW)
{
pinfo= (PIP_ADAPTER_INFO)malloc(len);
nError = GetAdaptersInfo(pinfo,&len);
if (nError==0)
{
ParseData();
}
}

return;
}
void ParseData()
{

if (pinfo!=NULL)
{
macaddress.Format("%02X:%02X:%02X:%02X:%02X:%02X",pinfo->Address[0],pinfo->Address[1],pinfo->Address[2],pinfo->Address[3],pinfo->Address[4],pinfo->Address[5]);
description = pinfo->Description;
type.Format("%d",pinfo->Type);

PIP_ADDR_STRING pAddressList = &(pinfo->IpAddressList);
IpAddress ="";
do
{
IpAddress += pAddressList->IpAddress.String;
pAddressList = pAddressList->Next;
if (pAddressList != NULL)
IpAddress +="\r\n";
} while (pAddressList != NULL);

subnet.Format("%s",pinfo->IpAddressList.IpMask.String);
gateway.Format("%s",pinfo->GatewayList.IpAddress.String);
if (pinfo->HaveWins)
PrimaryWinsServer.Format("%s",pinfo->PrimaryWinsServer.IpAddress.String );
else
PrimaryWinsServer.Format("%s","N/A" );
if (pinfo->DhcpEnabled )
dhcp.Format("%s",pinfo->DhcpServer.IpAddress.String );
else
dhcp.Format("%s","N/A");
pinfo = pinfo->Next;
}
OutPut("网络设备为:\t"+description);
OutPut("Mac 地址为:\t"+macaddress);
OutPut("网卡类型:\t"+type);
OutPut("IP 地址:\t"+IpAddress);
OutPut("子网掩码:\t"+subnet);
OutPut("网关:\t"+gateway);
OutPut("主 Wins 服务器:\t"+PrimaryWinsServer);
OutPut("dhcp 服务器:\t"+dhcp);




}

void OutPut(CString str)
{
cout< <}



摘自:网易社区


Only you!!!

[1]

[1]

在百度搜索:取得网卡的一些信息的代码
  • 上一个计算机:

  • 下一个计算机:
  • 相 关 文 章
  • C源码:通过IP地址查找主

  • 自己写程序揭开cmos密码

  • C 语言中操作字符串的一

  • Linux 内核原代码 init/

  • Linux 内核原代码 boot.

  • Linux 内核原代码 head.

  • linux 内核原代码 sched

  • 服务器和客户机的信息函

  • 谈谈代码风格──谈谈缩

  • Linux核心代码分析

  • connect超时时间的一点探

  • 迭代算法解题的一般思路

  • 递归算法解题的一般思路

  • 穷举算法解题的一般思路

  • 贪婪算法解题的一般思路

  • 几行代码,可画所有函数的

  • 以前常用的攻击软件源代

  • 上海黑暗之龙--麻将原代

  • 不要看代码冗长,我们只

  • 用栈设置密码

  • 栈和队列的一个应用

  • 程序设计:哈希表的一个

  • 对马踏棋盘的一点研究

  • 开机密码

  • 限次程序C语言源码

  • 用C语言编的一个日历

  • C语言程序源代码下载

  • 职工管理系统(系统密码

  • 一个简单的一箭穿心程序

  • 通讯录的源代码(用链表