之前写过两篇博客,介绍了windows的WMI技术,以及如果通过WMI获取显卡详细信息:
Windows客户端开发–WMI技术介绍
Windows客户端开发–使用WMI获取显卡详细信息(win32控制台程序)
关于获取电脑的mac地址,之前也有相关博客进行了介绍,使用的是QT:
qt中查看本机mac/ip地址
什么是mac地址?
MAC(Media Access Control或者Medium Access Control)地址,意译为媒体访问控制,或称为物理地址、硬件地址,用来定义网络设备的位置。在OSI模型中,第三层网络层负责 IP地址,第二层数据链路层则负责 MAC地址。因此一个主机会有一个MAC地址,而每个网络位置会有一个专属于它的IP地址。
WIKI上是这样描述的:
This article is about the network addressing term. For the series of personal computers by Apple Inc., see Macintosh. For other similar terms, see Mac.
Label of an UMTS router with MAC addresses for LAN and WLAN modules
A media access control address (MAC address) of a computer is a unique identifier assigned to network interfaces for communications at the data link layer of a network segment. MAC addresses are used as a network address for most IEEE 802 network technologies, including Ethernet and WiFi. Logically, MAC addresses are used in the media access control protocol sublayer of the OSI reference model.
MAC addresses are most often assigned by the manufacturer of a network interface controller (NIC) and are stored in its hardware, such as the card’s read-only memory or some other firmware mechanism. If assigned by the manufacturer, a MAC address usually encodes the manufacturer’s registered identification number and may be referred to as the burned-in address (BIA). It may also be known as an Ethernet hardware address (EHA), hardware address or physical address (not to be confused with a memory physical address). This can be contrasted to a programmed address, where the host device issues commands to the NIC to use an arbitrary address.
通过WMI获取本机的mac地址:
因为之前已经写过了,所以直接就上代码了:
#define _WIN32_DCOM
#include <iostream>
using namespace std;
#include <comdef.h>
#include <Wbemidl.h>
#include <string>
#pragma comment(lib, "wbemuuid.lib")
i