Click here to Skip to main content
15,567,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is there any way to get CPU_ID from C++ cli code..btw definition of CPU_ID is very vague so i dont really know where actually is this CPU_ID in the system

What I have tried:

i can get ipv4 mac address and all that but cant get CPU_ID
Any thoughts?
Posted
Updated 7-Aug-21 10:02am

got it working tanks every one for help
// WMI.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include <array>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include<conio.h>
std::string GetProcessorId() {
	std::array<int, 4> cpuInfo;
	__cpuid(cpuInfo.data(), 1);
	std::ostringstream buffer;
	buffer
		<< std::uppercase << std::hex << std::setfill('0')
		<< std::setw(8) << cpuInfo.at(3)
		<< std::setw(8) << cpuInfo.at(0);
	return buffer.str();
}

int main(void) {
	std::cout << "Processor Serial number is:  ";
		std::cout<<GetProcessorId() << std::endl;
	_getch();
	return 0;
}
 
Share this answer
 
This so post CPU ID using C++ - windows - Stack Overflow[^] holds a couple of answers which can sched a light on how to get this information.
 
Share this answer
 
Comments
Member 12899279 30-Jan-20 9:02am    
read this already its of no use as it just tells if the cpu is genuine intel or not and thats of no use
phil.o 30-Jan-20 9:07am    
The have you read this[^], and especially CPUID usage from high-level languages[^]?
Member 12899279 30-Jan-20 9:26am    
just read it
it has many things but not processor or cpu_id that i am looking for
Does this help? CAMEL - CPU Identifier Class[^]
 
Share this answer
 
Comments
Member 12899279 2-Feb-20 23:23pm    
no but thanks for trying

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900