c++ 读注册表信息 读取CPU信息

// regedit_find.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <sstream>
using namespace std;

const int BUFFER_SIE = 1000;

int _tmain(int argc, _TCHAR* argv[])
{
	long lRet;
	HKEY hKey;
	TCHAR tchData[BUFFER_SIE];
	DWORD dwSize;
	// 打开注册表(if open the regedit succeed,the function return ERROR_SUCCESS which define
	// in WINERROR.H and equal to 0);
	// 如果函数调用成功,则返回0(ERROR_SUCCESS)。
	// 否则,返回值为文件WINERROR.h中定义的一个非零的错误代码。
	
	lRet = RegOpenKeyEx(
		HKEY_LOCAL_MACHINE, // 主键 PrimaryKey
		_T("Hardware\\Description\\System\\CentralProcessor\\0"), //子健 subkey
		0,
		KEY_QUERY_VALUE, // 允许查询子健 allow to query the subkey
		&hKey
		);

	if (lRet == ERROR_SUCCESS)
	{
		// 查询注册表(Query the regedit)
		dwSize = BUFFER_SIE; // 这里是预留大小,不然会溢出造成 RegQueryValueExW return 234; if dwSize is not big enough,RegQueryValueExW will return 234;
	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值