通过注册表获取计算机相关信息
RegOpenKey()
capGetDriverDescription()
// Test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <Vfw.h>
#pragma comment(lib,"Vfw32.lib")
using namespace std;
DWORD CPUClockMHz();
BOOL WebCamIsExist();
int main()
{
CPUClockMHz();
WebCamIsExist();
return 0;
}
DWORD CPUClockMHz()
{
HKEY KeyHandle;
DWORD CPUMHz;
DWORD ReturnLength = sizeof(DWORD);
DWORD Type = REG_DWORD;
RegOpenKey(HKEY_LOCAL_MACHINE,
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &KeyHandle);
RegQueryValueEx(KeyHandle, L"~MHz", NULL, &Type, (PBYTE)&CPUMHz, &ReturnLength);
RegCloseKey(KeyHandle);
return CPUMHz;
}
BOOL WebCamIsExist()
{
BOOL bOk = FALSE;
WCHAR DeviceName[100], v1[50];
for (int i = 0; i < 10 && !bOk; i++)
{
bOk = capGetDriverDescription(i, DeviceName, sizeof(DeviceName),
//系统的API函数
v1, sizeof(v1));
}
return bOk;
}