This is going to be operating system dependent. Which platform are you asking for?
2007-11-15 18:13:48
·
answer #1
·
answered by mdigitale 7
·
0⤊
0⤋
This isn't an easy task because reading the serial number is a processor specific operation, which means you're probably going to have to write some assembly code. If you have an Intel CPU, you can use the CPUID function. AMD supports CPUID as well, but operation 3 (which reads the serial number) doesn't seem to be supported. They may not even have a user readable serial number, I'm not sure.
It sounds like this program might be run on multiple machines so what you'll probably have to do is use another method, like maybe the hard drive serial number or mac address.
If you're interested, here's an UNTESTED function to use CPUID. It failed on my AMD machine here, but it might work for you. Sorry about the formatting.... Yahoo Answers doesn't like tabs.
bool GetCPUID(void)
{
// The serial number is a 96-bit value so we have to break up the
// number into three unsigned int's.
unsigned int upper = 0;
unsigned int middle = 0;
unsigned int lower = 0;
__asm
{
// To use CPUID, fill EAX with a number corresponding to the operation
// you wish to perform. In this case we want the serial number, which
// is operation 3, however; some CPU's (like AMD) don't support it. So,
// we need to call CPUID with operation 0, which will get the vendor ID
// and replace EAX with the highest supported operation.
mov eax, 0
cpuid
// If EAX < 3, the processor doesn't support getting the serial number
// with CPUID. We're hosed, so jump to the end.
cmp eax, 3
jl done
// If we get here, the processor does support getting the serial number.
// We need to call CPUID again with EAX set to 3. The value is a 96 bit
// number returned in EBX:EDX:ECX, so we need to clear those registers.
mov eax, 3
mov ebx, 0
mov edx, 0
mov ecx, 0
cpuid
// store the values in our C variables
mov upper, ebx
mov middle, edx
mov lower, ecx
done:
}
// If upper, middle, and lower are all still 0 it means we failed because the
// processor doesn't support CPUID.
if (upper == 0 && middle == 0 && lower == 0)
{
printf("Failed\n");
return false; // failed
}
// Success, so write them to a file or do whatever you additional processing
// you want to do. Here I just print them out since it's only an example.
else
{
printf("Success!\nUpper: 0x%x\nMiddle: 0x%x\nLower: 0x%x\nFull ID: 0x%x%x%x\n",upper,middle,lower,upper,middle,lower);
return true; // success
}
}
2007-11-16 03:56:21
·
answer #2
·
answered by Rez 1
·
0⤊
0⤋
In XP type Processor in the help and support
in the results all your hardware is shown except RAM which is unfortunate.
click >start >help and support >processor
2007-11-16 02:14:24
·
answer #3
·
answered by chezzrob 7
·
0⤊
1⤋