🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Processor Name,OS version and Free Memory

#7760
From: Remy Lebeau (TeamB)
Date: Mon, 27 Dec 2004 09:12
113 lines
4221 bytes
"Sudesh" <sudeshc@vfemail.net> wrote in message
news:41cfb21f@newsgroups.borland.com...

> 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
Technical Details
Message-ID: <41cfd1af$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!feeder1.cambrium.nl!feed.tweaknews.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41cfb21f@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,3738055f2876cd07
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <41cfb21f@newsgroups.borland.com>
Subject: Re: Processor Name,OS version and Free Memory
Date: Mon, 27 Dec 2004 01:12:31 -0800
Lines: 115
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <41cfd1af$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1104138671 68.69.17.41 (27 Dec 2004 01:11:11 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!feeder1.cambrium.nl!feed.tweaknews.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail