🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Processor Name,OS version and Free Memory

#7766
From: Sudesh
Date: Mon, 27 Dec 2004 11:52
124 lines
4546 bytes
Thanks Remy
I think I have to link Kernel32.dll correct?
Sudesh

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:41cfd1af$1@newsgroups.borland.com...
>
> "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: <41cff768@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!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> <41cfd1af$1@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: "Sudesh" <sudeshc@vfemail.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <41cfb21f@newsgroups.borland.com> <41cfd1af$1@newsgroups.borland.com>
Subject: Re: Processor Name,OS version and Free Memory
Date: Mon, 27 Dec 2004 17:22:19 +0530
Lines: 126
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2096
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2096
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 220.224.53.237
Message-ID: <41cff768@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1104148328 220.224.53.237 (27 Dec 2004 03:52:08 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!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