如何获得网卡的硬件地址(MAC地址)? 如何获得网卡的硬件地址(MAC地址)? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 PIP_ADAPTER_INFO pinfo = NULL;m_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]); int WSAReturn; char Hostname[260]; char Hostaddress[20]; WSAReturn=WSAStartup( 0x0101, &WSAData ); if( WSAReturn == 0 ){ gethostname( Hostname, 260 ); struct hostent *pHostEnt; pHostEnt = gethostbyname( Hostname); if( pHostEnt != NULL ){ wsprintf( Hostaddress, "%d.%d.%d.%d", ( pHostEnt->h_addr_list[0][0] & 0x00ff ), ( pHostEnt->h_addr_list[0][1] & 0x00ff ), ( pHostEnt->h_addr_list[0][2] & 0x00ff ), ( pHostEnt->h_addr_list[0][3] & 0x00ff ) ); } } http://www.vctop.com/View.Asp?ID=400&CateID=1 楼主要的是MAC地址,不是IP地址#include "stdafx.h"#include <windows.h>#include <wincon.h>#include <stdlib.h>#include <stdio.h>#include <time.h>#include "Nb30.h"typedef struct _ASTAT_{ ADAPTER_STATUS adapt; NAME_BUFFER NameBuff [30]; }ASTAT, * PASTAT;ASTAT Adapter;int main(int argc, char* argv[]){ NCB Ncb; UCHAR uRetCode; char NetName[50]; LANA_ENUM lenum; int i; memset( &Ncb, 0, sizeof(Ncb) ); Ncb.ncb_command = NCBENUM; Ncb.ncb_buffer = (UCHAR *)&lenum; Ncb.ncb_length = sizeof(lenum); uRetCode = Netbios( &Ncb ); printf( "The NCBENUM return code is: 0x%x \n", uRetCode ); for(i=0; i < lenum.length ;i++) { memset( &Ncb, 0, sizeof(Ncb) ); Ncb.ncb_command = NCBRESET; Ncb.ncb_lana_num = lenum.lana[i]; uRetCode = Netbios( &Ncb ); printf( "The NCBRESET on LANA %d return code is: 0x%x \n", lenum.lana[i], uRetCode ); memset( &Ncb, 0, sizeof (Ncb) ); Ncb.ncb_command = NCBASTAT; Ncb.ncb_lana_num = lenum.lana[i]; strcpy( (char*)Ncb.ncb_callname, "* " ); Ncb.ncb_buffer = (unsigned char *) &Adapter; Ncb.ncb_length = sizeof(Adapter); uRetCode = Netbios( &Ncb ); printf( "The NCBASTAT on LANA %d return code is: 0x%x \n", lenum.lana[i], uRetCode ); if ( uRetCode == 0 ) { printf( "The Ethernet Number on LANA %d is:%02x-%02x-%02x-%02x-%02x-%02x\n", lenum.lana[i], Adapter.adapt.adapter_address[0], Adapter.adapt.adapter_address[1], Adapter.adapt.adapter_address[2], Adapter.adapt.adapter_address[3], Adapter.adapt.adapter_address[4], Adapter.adapt.adapter_address[5] ); } } return 0; } #include "stdafx.h"#include <windows.h>#include <wincon.h>#include <stdlib.h>#include <stdio.h>#include <time.h>#pragma comment(lib,"netapi32.lib")typedef struct _ASTAT_{ ADAPTER_STATUS adapt; NAME_BUFFER NameBuff [30];}ASTAT, * PASTAT;ASTAT Adapter;int main(int argc, char* argv[]){ NCB ncb; UCHAR uRetCode; memset( &ncb, 0, sizeof(ncb) ); ncb.ncb_command = NCBRESET; ncb.ncb_lana_num = 0; uRetCode = Netbios( &ncb ); printf( "The NCBRESET return code is: 0x%x \n", uRetCode ); memset( &ncb, 0, sizeof(ncb) ); ncb.ncb_command = NCBASTAT; ncb.ncb_lana_num = 0; strcpy((char*) ncb.ncb_callname, "*" ); ncb.ncb_buffer = (unsigned char *) &Adapter; ncb.ncb_length = sizeof(Adapter); uRetCode = Netbios( &ncb ); printf( "The NCBASTAT return code is: 0x%x \n", uRetCode ); if ( uRetCode == 0 ) { printf( "The Ethernet Number is: %02x%02x%02x%02x%02x%02x\n", Adapter.adapt.adapter_address[0], Adapter.adapt.adapter_address[1], Adapter.adapt.adapter_address[2], Adapter.adapt.adapter_address[3], Adapter.adapt.adapter_address[4], Adapter.adapt.adapter_address[5] ); } return 0;}win2000+vc6.0 100分,(IIS)Web服务器写权限 想做个b/s的程序,用什么实现好? MMC控制台程序应该怎么写? 如何用程序方式给CRichEdit追加文字 如何制作vc数据库安装程序? 怎样在程序里改变本进程的优先级别? 高程成绩怎么查??(江西的) windows下编程实现release ip 和 renew ip如何知道成功? 各位大侠,小弟有一个关于UDP数据报收发的问题,请指教 WS_MINIMIZEBOX和WS_GROUP,WS_TABSTOP和WS_MAXIMIZEBOX怎么区别 哪里有http协议的资料,最好是中文的 怎样旋转一个RECT?
char Hostname[260];
char Hostaddress[20];
WSAReturn=WSAStartup( 0x0101, &WSAData );
if( WSAReturn == 0 ){
gethostname( Hostname, 260 );
struct hostent *pHostEnt;
pHostEnt = gethostbyname( Hostname);
if( pHostEnt != NULL ){
wsprintf( Hostaddress, "%d.%d.%d.%d",
( pHostEnt->h_addr_list[0][0] & 0x00ff ),
( pHostEnt->h_addr_list[0][1] & 0x00ff ),
( pHostEnt->h_addr_list[0][2] & 0x00ff ),
( pHostEnt->h_addr_list[0][3] & 0x00ff ) );
}
}
#include <windows.h>
#include <wincon.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "Nb30.h"typedef struct _ASTAT_
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff [30];
}ASTAT, * PASTAT;ASTAT Adapter;
int main(int argc, char* argv[])
{
NCB Ncb;
UCHAR uRetCode;
char NetName[50];
LANA_ENUM lenum;
int i;
memset( &Ncb, 0, sizeof(Ncb) );
Ncb.ncb_command = NCBENUM;
Ncb.ncb_buffer = (UCHAR *)&lenum;
Ncb.ncb_length = sizeof(lenum);
uRetCode = Netbios( &Ncb );
printf( "The NCBENUM return code is: 0x%x \n", uRetCode );
for(i=0; i < lenum.length ;i++)
{
memset( &Ncb, 0, sizeof(Ncb) );
Ncb.ncb_command = NCBRESET;
Ncb.ncb_lana_num = lenum.lana[i];
uRetCode = Netbios( &Ncb );
printf( "The NCBRESET on LANA %d return code is: 0x%x \n",
lenum.lana[i], uRetCode );
memset( &Ncb, 0, sizeof (Ncb) );
Ncb.ncb_command = NCBASTAT;
Ncb.ncb_lana_num = lenum.lana[i];
strcpy( (char*)Ncb.ncb_callname, "* " );
Ncb.ncb_buffer = (unsigned char *) &Adapter;
Ncb.ncb_length = sizeof(Adapter);
uRetCode = Netbios( &Ncb );
printf( "The NCBASTAT on LANA %d return code is: 0x%x \n",
lenum.lana[i], uRetCode );
if ( uRetCode == 0 )
{
printf( "The Ethernet Number on LANA %d is:%02x-%02x-%02x-%02x-%02x-%02x\n",
lenum.lana[i],
Adapter.adapt.adapter_address[0],
Adapter.adapt.adapter_address[1],
Adapter.adapt.adapter_address[2],
Adapter.adapt.adapter_address[3],
Adapter.adapt.adapter_address[4],
Adapter.adapt.adapter_address[5] );
}
}
return 0;
}
#include <windows.h>
#include <wincon.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#pragma comment(lib,"netapi32.lib")
typedef struct _ASTAT_
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff [30];
}ASTAT, * PASTAT;ASTAT Adapter;int main(int argc, char* argv[])
{
NCB ncb;
UCHAR uRetCode;
memset( &ncb, 0, sizeof(ncb) );
ncb.ncb_command = NCBRESET;
ncb.ncb_lana_num = 0; uRetCode = Netbios( &ncb );
printf( "The NCBRESET return code is: 0x%x \n", uRetCode ); memset( &ncb, 0, sizeof(ncb) );
ncb.ncb_command = NCBASTAT;
ncb.ncb_lana_num = 0; strcpy((char*) ncb.ncb_callname, "*" );
ncb.ncb_buffer = (unsigned char *) &Adapter;
ncb.ncb_length = sizeof(Adapter); uRetCode = Netbios( &ncb );
printf( "The NCBASTAT return code is: 0x%x \n", uRetCode );
if ( uRetCode == 0 )
{
printf( "The Ethernet Number is: %02x%02x%02x%02x%02x%02x\n",
Adapter.adapt.adapter_address[0],
Adapter.adapt.adapter_address[1],
Adapter.adapt.adapter_address[2],
Adapter.adapt.adapter_address[3],
Adapter.adapt.adapter_address[4],
Adapter.adapt.adapter_address[5] );
} return 0;
}win2000+vc6.0