🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7123

Re: reading unique CPU number

#7123
From: Vladimir Stefanovic
Date: Sun, 13 Mar 2005 18:20
124 lines
4336 bytes
This is what Gambit said about that:

<quote>

> How to get Processor Name

There is nothing in the Win32 API to retreive the processor name.   You can
use GetSystemInfo() to determine the type of processor, but to get its name
you have to query the CPU directly, via the assembly CPUID instruction.  For
example:

    typedef long TCPUID[4];
    typedef char TVendor[12];

    #pragma option push -w-

    bool IsCPUID_Available(void)
    {
        __asm
        {
            PUSHFD          // direct access to flags no possible, only via
stack
            POP     EAX     // flags to EAX
            MOV     EDX,EAX // save current flags
            XOR     EAX,0x00200000  // not ID bit
            PUSH    EAX     // onto stack
            POPFD           // from stack to flags, with not ID bit
            PUSHFD          // back to stack
            POP     EAX     // get back to EAX
            XOR     EAX,EDX // check if ID bit affected
            SHR     EAX,21  // Result=Bit #21
        }
    }

    void __fastcall GetCPUID(TCPUID* cpuID)
    {
        __asm
        {
            PUSH    EBX     // Save affected register
            PUSH    EDI
            MOV     EDI,EAX // cpuID
            MOV     EAX,1
            DW      0xA20F  // CPUID Command
            STOSD           // CPUID[1]
            MOV     EAX,EBX
            STOSD           // CPUID[2]
            MOV     EAX,ECX
            STOSD           // CPUID[3]
            MOV     EAX,EDX
            STOSD           // CPUID[4]
            POP     EDI     // Restore registers
            POP     EBX
        }
    }

    void __fastcall GetCPUVendor(TVendor* vendor)
    {
        __asm
        {
            PUSH    EBX     // Save affected register
            PUSH    EDI
            MOV     EDI,EAX // vendor
            MOV     EAX,0
            DW      0xA20F  // CPUID Command
            MOV     EAX,EBX
            STOSD
            MOV     EAX,EDX
            STOSD
            MOV     EAX,ECX
            STOSD
            POP     EDI     // Restore registers
            POP     EBX
        }
    }

    #pragma option pop

    if( IsCPUID_Available() )
    {
        TCPUID  cpuID;
        GetCPUID(&cpuID);
        // use CPU feature flags as needed...

        TVendor vendor;
        GetCPUVendor(&vendor);
        // use vendor description as needed...
    }

Go to Intel's website and refer to the document titled "Intel Architecture
Software Developr's Manual, Volume 2: Instruction Set Reference" for
specific details about how the CPUID instruction works.

> Windows version

    GetVersionEx()
    http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp

    Getting the System Version

http://msdn.microsoft.com/library/en-us/sysinfo/base/getting_the_system_version.asp

> and Free Memory of the PC?

    GlobalMemoryStatus()

http://msdn.microsoft.com/library/en-us/memory/base/globalmemorystatus.asp

    GlobalMemoryStatusEx()

http://msdn.microsoft.com/library/en-us/memory/base/globalmemorystatusex.asp


Gambit


</quote>

-- 
Best regards,
Vladimir Stefanovic
<Harry> wrote in message news:423438a3@newsgroups.borland.com...
> Is there such thing as unique number on each Intel Pentium CPUs?
> If so how can we read that number within BCB?
> 
Technical Details
Message-ID: <4234847b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <423438a3@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,13e124f8a5f82d75
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Vladimir Stefanovic" <antivari@po.sbb.co.yu>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <423438a3@newsgroups.borland.com>
Subject: Re: reading unique CPU number
Date: Sun, 13 Mar 2005 19:20:48 +0100
Lines: 126
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 82.117.212.65
Message-ID: <4234847b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1110738043 82.117.212.65 (13 Mar 2005 10:20:43 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail