[C++] "realtime" cpu frequentie uitlezen onder windows

Pagina: 1
Acties:
  • 644 views

Acties:
  • 0 Henk 'm!

  • janwillemCA
  • Registratie: Mei 2014
  • Laatst online: 09:12
hallo,

ik ben een grafische applicatie aan het schrijven voor Windows.
Deze applicatie zal o.a wat feedback geven over het systeem waarop de applicatie draait.
Denk hierbij aan o.a: beschikbaar geheugen, gebruikt geheugen e.t.c.

Nu wil ik ook graag wat processor informatie (klok frequenties) weergeven. Ik ben al wat aan het klooien geweest met __cpuid, maar ik kom hier nog niet helemaal uit.

dit is wat ik momenteel heb, en werkt in cmd.

C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <intrin.h>
#include <tchar.h>

using namespace std;

int cpuInfo(int argc, _TCHAR* argv[])
{
    
// Get extended ids.
     int CPUInfo[4] = {-1};
     __cpuid(CPUInfo, 0x80000000);
     unsigned int nExIds = CPUInfo[0];
 
     // Get the information associated with each extended ID.
     char CPUBrandString[0x40] = { 0 };
     for( unsigned int i=0x80000000; i<=nExIds; ++i)
     {
         __cpuid(CPUInfo, i);
 
         // Interpret CPU brand string and cache information.
         if  (i == 0x80000002)
         {
             memcpy( CPUBrandString,
             CPUInfo,
             sizeof(CPUInfo));
         }
         else if( i == 0x80000003 )
         {
             memcpy( CPUBrandString + 16,
             CPUInfo,
             sizeof(CPUInfo));
         }
         else if( i == 0x80000004 )
         {
             memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
         }
 }
 
     cout << "Cpu String: " << CPUBrandString;
     system("pause");
 }


Onder Unix/Linux weet ik wel hoe dit makkelijk gedaan kan worden, maar ik ken Windows niet zo goed..

Heeft iemand tips?

Mvg, Jan Willem Casteleijn

Unix is simple. It just takes a genius to understand its simplicity


Acties:
  • 0 Henk 'm!

  • janwillemCA
  • Registratie: Mei 2014
  • Laatst online: 09:12
Heb overigens dit nog gevonden,

http://stackoverflow.com/...ram-usage-in-c-on-windows

Misschien dat het wil

Unix is simple. It just takes a genius to understand its simplicity


Acties:
  • 0 Henk 'm!

  • MSalters
  • Registratie: Juni 2001
  • Laatst online: 13-09 00:05
Heb je gezien dat er op StackOverflow rechtsboven een search veld zit? Daar kun je bijvoorbeeld "CPU cklock frequency" invullen.

Man hopes. Genius creates. Ralph Waldo Emerson
Never worry about theory as long as the machinery does what it's supposed to do. R. A. Heinlein


Acties:
  • 0 Henk 'm!

  • Soultaker
  • Registratie: September 2000
  • Laatst online: 01:41
Gebruik alsjeblieft [code=C++][/code] tags om je code te formatteren.

Acties:
  • 0 Henk 'm!

  • janwillemCA
  • Registratie: Mei 2014
  • Laatst online: 09:12
Soultaker schreef op dinsdag 31 maart 2015 @ 10:39:
Gebruik alsjeblieft [code=C++][/code] tags om je code te formatteren.
Aangepast, bedankt voor de tip. Post hier eigenlijk nooit wat, vandaar.

Ik zal stackoverflow eens doorspitten inderdaad. Zal vast wel wat over te vinden zijn.

Unix is simple. It just takes a genius to understand its simplicity


Acties:
  • 0 Henk 'm!

  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 14-10 22:12

Creepy

Tactical Espionage Splatterer

Mocht je dan wat gevonden en het mocht alsnog niet lukken, dan kan je weer een nieuw topic openen. Hier gaan we er vanuit dat je in eerste instantie zelf opzoek gaat naar een oplossing en dat je dan ook aangeeft wat je hebt geprobeerd en wat daar mis mee ging.

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney

Pagina: 1

Dit topic is gesloten.