关于获取硬件信息

常用设备的接口GUID如下:

设备接口名称

GUID

USB Raw Device/USB设备

{a5dcbf10-6530-11d2-901f-00c04fb951ed}

Disk Device/磁盘设备

{53f56307-b6bf-11d0-94f2-00a0c91efb8b}

Network Card/网卡

{ad498944-762f-11d0-8dcb-00c04fc3358c}

Human Interface Device (HID)/人机界面设备

{4d1e55b2-f16f-11cf-88cb-001111000030}

Palm/手持设备

{784126bf-4190-11d4-b5c2-00c04f687a67}



#include "stdafx.h"
#include <atlbase.h>
#include <atlconv.h>
#include "iphlpapi.h"
#pragma comment ( lib, "Iphlpapi.lib" )
/////////////////////////////////////////////////////////////////////

获取网卡信息代码

/////////////////////////////////////////////////////////////////////

void main()
{
PIP_ADAPTER_INFO pAdapterInfo;
PIP_ADAPTER_INFO pAdapter = NULL;
DWORD dwRetVal = 0;
ULONG ulOutBufLen;
pAdapterInfo=(PIP_ADAPTER_INFO)malloc(sizeof(IP_ADAPTER_INFO));
ulOutBufLen = sizeof(IP_ADAPTER_INFO);


// 第一次调用GetAdapterInfo获取ulOutBufLen大小
if (GetAdaptersInfo( pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW)
{
free(pAdapterInfo);
pAdapterInfo = (IP_ADAPTER_INFO *) malloc (ulOutBufLen); 
}


if ((dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen)) == NO_ERROR) {
pAdapter = pAdapterInfo;
while (pAdapter) 
{
printf("Adapter Name: \t%s\n", pAdapter->AdapterName);
printf("Adapter Desc: \t%s\n", pAdapter->Description);
printf("MAC Addr: \t%02x-%02x-%02x-%02x-%02x-%02x\n", 
pAdapter->Address[0],
pAdapter->Address[1],
pAdapter->Address[2],
pAdapter->Address[3],
pAdapter->Address[4],
pAdapter->Address[5]);
printf("IP Address: \t%s\n", pAdapter->IpAddressList.IpAddress.String);
printf("IP Mask: \t%s\n", pAdapter->IpAddressList.IpMask.String); 
printf("Gateway: \t%s\n", pAdapter->GatewayList.IpAddress.String);
pAdapter = pAdapter->Next;
}
}
else
{
printf("Call to GetAdaptersInfo failed.\n");
}
getchar();
}


SELECT * FROM Win32_BaseBoard WHERE (SerialNumber IS NOT NULL)

SELECT * FROM Win32_BIOS WHERE (SerialNumber IS NOT NULL)

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭