C Code - get system spec

Soldato
Joined
22 Oct 2005
Posts
2,883
Location
Moving...
Hi guys.

I've written an application and its nearing its final stages. One of the things I want to add is a sort of performance checker, i.e. before running the program it will get some system information and set some variables relating to the performance accordingly. So if the system had only 256MB ram it wouldn't load as much data.

Is there any C functions/library where I can retreive such data? It only needs to be very basic, e.g processor speed, amount of ram installed, graphics card size (this is most important as its a graphics based program).

Thanks for any advice.
 
Thats the style I'm after, but not quite the data I'm after. Ideally I would like:

- Processor speed
- No. of cores (found)
- Total Ram installed (or available ram)
- Graphics card size e.g. 256MB (core and mem speeds would be an added bonus)

Thanks again.
 
As far as RAM goes, does it matter how much is installed? I'd have thought you should attempt to allocate as much as you want. If that fails, try to allocate less. Repeat until you've either allocated memory, or failed to allocate the minimum required size!

Clock speed is a tricky one to ascertain, and even harder to make sense of. Could you run a benchmark of sorts, either when your app starts, or the first time it starts?

Sounds like you want one thread per core or something similar? In Vista you can call GetLogicalProcessorInformation - which returns you the number of cores. Before Vista, you need to fiddle about with CPUID instuctions directly. A pain, but I'm sure you'll find libraries available to do it.
 
Well I've used the processor speed code from the link Shadez provided, it looks to me like some kind of benchmark but it gets it spot on for my system and doesn't take long to run so that fine.

And you're right, RAM isn't actually that important, but it would be nice to know the maximum space I can allocate before running the program rather than failing halfway through it.

It's really the graphics card data that is most important to me because it's so graphics intensive.

Thanks again for all your swift replies.


**edit** - I've got the memory sorted using GlobalMemoryStatusEx, it's just the graphics card info now
 
Last edited:
Back
Top Bottom