如何读取CPU的序列号或则其他信息???

blcr 2003-08-20 08:44:01

我想读取CPU的序列号或者其他信息,但不知道如何做?请大家帮帮忙。谢谢!!!
...全文
97 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bborn 2003-08-20
  • 打赏
  • 举报
回复
Supports Microsoft® Windows™ From:
Windows™ 95 / 95 OSR2 / 95 OSR2.5
Windows™ 98 / 98 SE
Windows™ Millennium
Windows™ NT 3.51
Windows™ NT 4.0 Workstation / Server [Including SP1 to SP6a]
Windows™ 2000 Workstation / Server / Advanced Server / Datacenter Server (Including SP1 to SP3)
Windows™ XP Personal / Professional [Including SP1]
Windows™ .NET Web Server / Standard Server / Enterprise Server
Supports Processors From:
Intel / AMD / Cyrix / Rise / UMC / IDT / Transmeta / NexGen / National Semiconductor

See Camel.txt for processor listings... E.g. Pentium III "Coppermine" or Athlon XP 1800+ (Thoroughbred Core).
Detects Hardware Features:
Processor hardware
Single Processors
Dual Processors
Multiple Processors
HyperThreading Technology
Serial Number [if enabled]
On-Chip APIC Hardware
Hard-Coded Chip Names
L1 Cache Size
L2 Cache Size
L3 Cache Size
CPU Clock Speed [of each processor]
Thermal Monitioring Support
ACPI Support
On-Chip PowerManagement [SpeedStep, etc.]

Multimedia Instruction Sets
MMX
MMX+
Streaming SIMD Extensions
Streaming SIMD Extensions [Floating Point]
Streaming SIMD Extensions [MMX]
Streaming SIMD Extensions 2
3DNow!
3DNow!+

General Instruction Sets
Floating Point Unit [FPU]
Time Stamp Counter [TSC]
Conditional Move [CMOV]
Memory Type Range Registers [MTRR]

approach 2003-08-20
  • 打赏
  • 举报
回复
(转)
//
// CPU identification
//

typedef struct {
unsigned nEAX;
unsigned nEBX;
unsigned nECX;
unsigned nEDX;
} CPUID_Output;

// Detect CPUID support
BOOL CPUID_Supported(void)
{
int nCpuidOk = 0;
__asm {
pushfd // Get eflags
pop eax
mov ecx,eax // Save original eflags
xor eax,0x00200000 // Toggle bit 21
push eax // Set new eflags
popfd
pushfd // Did it change?
pop eax
cmp eax,ecx
je no_cpuid
mov nCpuidOk,1
no_cpuid:
push ecx // Be nice and restore eflags
popfd
}
return nCpuidOk;
}

void CPUID(CPUID_Output *pResult, int nFunction)
{
__asm {
mov eax,nFunction
xor ebx,ebx
xor ecx,ebx
xor edx,ebx
cpuid
mov edi,pResult
mov [edi.nEAX],eax
mov [edi.nEBX],ebx
mov [edi.nECX],ecx
mov [edi.nEDX],edx
}
}

int IdentifyProcessor(char *pSerial)
{
CPUID_Output cid;
int nMaxFunc, nMaxFuncExt;
unsigned aVendorStr[4];
char *pVendorStr = (char*)aVendorStr;

pSerial[0] = 0;

if (!CPUID_Supported())
return 0;

// Check maximum CPUID function supported
//
CPUID(&cid, 0x00000000);
nMaxFunc = cid.nEAX;
aVendorStr[0] = cid.nEBX;
aVendorStr[1] = cid.nEDX;
aVendorStr[2] = cid.nECX;
aVendorStr[3] = 0;

if (nMaxFunc < 1)
return 0;

// Get serial number
if (nMaxFunc >= 3) {
CPUID(&cid, 0x00000003);

sprintf(pSerial, "%04x:%04x",
cid.nECX, cid.nEDX);
return 1;
}
return 0;
}
bborn 2003-08-20
  • 打赏
  • 举报
回复
这个类很好用
bborn 2003-08-20
  • 打赏
  • 举报
回复
我要分啊 这里有个很好的类
http://www.codeproject.com/system/camel.asp

一定要给分!
howtotell 2003-08-20
  • 打赏
  • 举报
回复
/*
函数:取得CPU启动到现在运行的周期数
*/
_int64 CSystemInfo::Count(void)
{
_asm
{
_emit 0x0F
_emit 0x31
}

}

/*
函数:取得CPU信息
*/
void CSystemInfo::GetCpu()
{
CString m_strCpuInfo;
m_strCpuInfo.Empty();
char OEMString[13];

int iEAXValue,iEBXValue,iECXValue,iEDXValue;

_asm {
mov eax,0
cpuid
mov DWORD PTR OEMString,ebx
mov DWORD PTR OEMString+4,edx
mov DWORD PTR OEMString+8,ecx
mov BYTE PTR OEMString+12,0
}

m_strCpuInfo.Format("%s",OEMString);

_asm {
mov eax,1
cpuid
mov iEAXValue,eax
mov iEBXValue,ebx
mov iECXValue,ecx
mov iEDXValue,edx
}

if(iEDXValue&0x800000)
{
m_strCpuInfo+=" MMX Support";
}
else
{
m_strCpuInfo+=" No MMX Support";
}
int iCPUFamily=(0xf00 & iEAXValue)>>8;

CString m_family;
m_family.Format("%s%d","\r\n Family: ",iCPUFamily);
m_strCpuInfo+=m_family;

CString Frequency;
_int64 start=Count();
Sleep(1000);
_int64 stop=Count();
UINT cpuspeed = (UINT)((stop-start)/1000000);
Frequency.Format("%d MHZ",cpuspeed);
CString cpuinfo;
cpuinfo.Format("%s%s","频率: ",Frequency);
m_strCpuInfo+=cpuinfo;
strcpy(cpu,m_strCpuInfo);

}
blcr 2003-08-20
  • 打赏
  • 举报
回复
有没有直接用VC++做的,或者一个函数直接调用???
akiko 2003-08-20
  • 打赏
  • 举报
回复
http://www.pcvc.net/category/content.asp?sendid=259

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧