windows怎么获取mac地址

windows怎么获取mac地址,第1张

最简单的 *** 作方法:

1、点击桌面开始、运行;

2、输入:CMD

3、输入:ipconfig /all

输入:ipconfig /all >D:\1txt 还可将信息保存到D盘命名为1txt的文件中。

注:网卡MAC地址即下图中的“物理地址”。

C++获取mac地址的代码:

#include <windowsh>

#include <stdlibh>

#include <stdioh>

#include <timeh>

/

Dev C++ -> include libnetapi32a

BCC 55 or VC++ -> #pragma comment(lib,"netapi32lib")

/

typedef struct _ASTAT_

{

ADAPTER_STATUS adapt;

NAME_BUFFER NameBuff [30];

} ASTAT, PASTAT;

void getMac(char mac)

{

ASTAT Adapter;

NCB Ncb;

UCHAR uRetCode;

LANA_ENUM lenum;

int i = 0;

memset(&Ncb, 0, sizeof(Ncb));

Ncbncb_command = NCBENUM;

Ncbncb_buffer = (UCHAR )&lenum;

Ncbncb_length = sizeof(lenum);

uRetCode = Netbios( &Ncb );

printf( "The NCBENUM return adapter number is: %d \n ", lenumlength);

for(i=0; i < lenumlength ; i++)

{

memset(&Ncb, 0, sizeof(Ncb));

Ncbncb_command = NCBRESET;

Ncbncb_lana_num = lenumlana[i];

uRetCode = Netbios( &Ncb );

memset(&Ncb, 0, sizeof(Ncb));

Ncbncb_command = NCBASTAT;

Ncbncb_lana_num = lenumlana[i];

strcpy((char )Ncbncb_callname, " ");

Ncbncb_buffer = (unsigned char ) &Adapter;

Ncbncb_length = sizeof(Adapter);

uRetCode = Netbios( &Ncb );

if (uRetCode == 0)

{

//sprintf(mac, "%02x-%02x-%02x-%02x-%02x-%02x ",

sprintf(mac, "%02X%02X%02X%02X%02X%02X ",

Adapteradaptadapter_address[0],

Adapteradaptadapter_address[1],

Adapteradaptadapter_address[2],

Adapteradaptadapter_address[3],

Adapteradaptadapter_address[4],

Adapteradaptadapter_address[5]

);

//printf( "The Ethernet Number on LANA %d is: %s\n ", lenumlana[i], mac);

}

}

}

int main(int argc, char argv[])

{

char mac=new char[32];

getMac(mac);

printf( "%s\n ", mac);

delete[]mac;

system( "PAUSE> NUL ");

return 0;

}

public class getInfo

{

/// <summary>

/// 获取CPU序列号

/// </summary>

/// <returns>CPU序列号(string类型 )</returns>

public string getCpuID()

{

string cpuInfo =" ";

ManagementClass cimobject = new ManagementClass("Win32_Processor");

ManagementObjectCollection moc = cimobjectGetInstances();

foreach (ManagementObject mo in moc)

{

cpuInfo = moProperties["ProcessorId"]ValueToString();

}

return cpuInfoToString();

} /// <summary>

/// 获取硬盘ID

/// </summary>

/// <returns>返回硬盘ID(string类型) </returns>

public string getHDid()

{

string HDid = " ";

ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive");

ManagementObjectCollection moc1 = cimobject1GetInstances();

foreach (ManagementObject mo in moc1)

{

HDid = (string)moProperties["Model"]Value;

}

return HDidToString(); } /// <summary>

/// 获取网卡硬地址

/// </summary>

/// <returns>返回网卡硬地址(string类型)</returns>

public string GetMoAddress()

{

string MoAddress =" ";

ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");

ManagementObjectCollection moc2 = mcGetInstances();

foreach (ManagementObject mo in moc2)

{

if ((bool)mo["IPEnabled"] == true)

{

MoAddress = mo["MacAddress"]ToString();

moDispose();

}

}

return MoAddressToString();

}

}</p>我空间日志写过,希望能帮到你

以上就是关于windows怎么获取mac地址全部的内容,包括:windows怎么获取mac地址、c++ 如何获取本机mac、C#获取本机MAC地址和CPU序列号 - - 求API函数 或者源码!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9506360.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-29
下一篇 2023-04-29

发表评论

登录后才能评论

评论列表(0条)

保存