MFC-Independent class for the easy determination of system information
Click here for larger image
Environment: VC++, WIN32 x86
I have seen MANY people ask for ways to determine different types of system information. Some people want to know the OS version; some want to know memory information; others want to know detailed information about the processor. All of this information, and more, is easily available with the SysInfo class.
There have been other classes in the past that one could use. SysInfo differs from these classes in a few ways:
- The SysInfo client is able to get exactly what he/she desires. No more sifting through long, text strings.
- The SysInfo class provides full source-code! Yes, if you don't like what I did, just modify it, or better yet, derive your own class.
- The SysInfo class is MFC-independent. This isn't an issue for a lot of CodeGuru readers, but there are some non-MFCers out there and this class should be easily available to them too ... without a lot of editing.
- The default project comes with static and dynamic link options. If you want everything bundled in your executable, that's fine by me!
Of course, everything isn't perfect with this class. Future enhancements include [but are not limited to]:
- IE and/or Windows Media player versions
- Comctl32.dll version
- Display information
- Directx information
- Printer information
- decent hardware detection
Known "issues" with SysInfo:
- The "algorithm" for determining speed is very rudimentary and should be improved upon.
- The conversion from bytes to MB [and bytes to GB] is a little off for larger drives.
It's fairly close though, so I left it alone.
Here's an example of how easy it is to use SysInfo.
#include "SysInfo.h" #include#include using namespace std; void main(int argc, char* argv[]) { SysInfo sysInfo; cout << "---------------------" << endl; cout << "PROCESSOR INFORMATION" << endl; cout << "---------------------" << endl; cout << "CPU String: " << sysInfo.getCpuIdentification() << endl; cout << "CPU Speed: " << sysInfo.getCpuSpeed() << endl; cout << "Number of CPUs: " << sysInfo.getNumProcessors() << endl; cout << "Family: " << sysInfo.getCpuFamily() << endl; cout << "Model: " << sysInfo.getCpuModel() << endl; cout << "Stepping: " << sysInfo.getCpuStepping() << endl; system("pause"); system("cls"); cout << "------------------" << endl; cout << "PROCESSOR FEATURES" << endl; cout << "------------------" << endl; cout << "FPU: " << sysInfo.getFeature(FPU_FLAG) << " " << "CMOV: " << sysInfo.getFeature(CMOV_FLAG) << endl; cout << "VME: " << sysInfo.getFeature(VME_FLAG) << " " << "PAT: " << sysInfo.getFeature(PAT_FLAG) << endl; cout << "DE: " << sysInfo.getFeature(DE_FLAG) << " " << "PSE36: " << sysInfo.getFeature(PSE36_FLAG) << endl; cout << "PSE: " << sysInfo.getFeature(PSE_FLAG) << " " << "PSNUM: " << sysInfo.getFeature(PSNUM_FLAG) << endl; cout << "TSC: " << sysInfo.getFeature(TSC_FLAG) << " " << "CLFLUSH: " << sysInfo.getFeature(CLFLUSH_FLAG) << endl; cout << "MSR: " << sysInfo.getFeature(MSR_FLAG) << " " << "DTS: " << sysInfo.getFeature(DTS_FLAG) << endl; cout << "PAE: " << sysInfo.getFeature(PAE_FLAG) << " " << "ACPI: " << sysInfo.getFeature(ACPI_FLAG) << endl; cout << "MCE: " << sysInfo.getFeature(MCE_FLAG) << " " << "MMX: " << sysInfo.getFeature(MMX_FLAG) << endl; cout << "CX8: " << sysInfo.getFeature(CX8_FLAG) << " " << "FXSR: " << sysInfo.getFeature(FXSR_FLAG) << endl; cout << "APIC: " << sysInfo.getFeature(APIC_FLAG) << " " << "SSE: " << sysInfo.getFeature(SSE_FLAG) << endl; cout << "SEP: " << sysInfo.getFeature(SEP_FLAG) << " " << "SSE2: " << sysInfo.getFeature(SSE2_FLAG) << endl; cout << "MTRR: " << sysInfo.getFeature(MTRR_FLAG) << " " << "SS: " << sysInfo.getFeature(SS_FLAG) << endl; cout << "PGE: " << sysInfo.getFeature(PGE_FLAG) << " " << "TM: " << sysInfo.getFeature(TM_FLAG) << endl; cout << "MCA: " << sysInfo.getFeature(MCA_FLAG) << endl; cout << "3dNow!: " << sysInfo.getExtFeature(HAS3DNOW_FLAG) << " " << "3dNow!Ex:" << sysInfo.getExtFeature(EXT3DNOW_FLAG) << endl; cout << "SSE MMX: " << sysInfo.getExtFeature(SSEMMX_FLAG) << endl; system("pause"); system("cls"); cout << "--------------" << endl; cout << "OS INFORMATION" << endl; cout << "--------------" << endl; cout << "OS: " << sysInfo.getOSDescription() << endl; cout << endl; cout << "------------------" << endl; cout << "MEMORY INFORMATION" << endl; cout << "------------------" << endl; cout << "Total: " << sysInfo.getTotalRam() << endl; cout << "Available: " << sysInfo.getAvailRam() << endl; cout << "Total Page: " << sysInfo.getTotalPageFile() << endl; cout << "Avail Page: " << sysInfo.getAvailPageFile() << endl; cout << "Total Virtual: " << sysInfo.getTotalVirtual() << endl; cout << "Avail Virtual: " << sysInfo.getAvailVirtual() << endl; system("pause"); system("cls"); cout << "------------------" << endl; cout << "SOCKET INFORMATION" << endl; cout << "------------------" << endl; cout << "Version: " << sysInfo.getSocketVersion() << endl; cout << "Highest Ver: " << sysInfo.getHighestSocketVersion() << endl; cout << "Description: " << sysInfo.getSocketDescription() << endl; cout << "System Status: " << sysInfo.getSocketSystemStatus() << endl; cout << "Max: " << sysInfo.getSocketMax() << endl; cout << "IP Address: " << sysInfo.getIPAddress() << endl; cout << "Domain Name: " << sysInfo.getDomainName() << endl; cout << "UDP Max: " << sysInfo.getSocketUdpMax() << endl; cout << endl; cout << "----------------------" << endl; cout << "HARD DRIVE INFORMATION" << endl; cout << "----------------------" << endl; vector const* pvDriveStats = sysInfo.getDriveStats(); vector ::const_iterator i; for (i = pvDriveStats->begin(); i != pvDriveStats->end(); i++) { cout << "Name: " << i->getName() << " Type: " << i->getType() << " Total: " << i->getTotalSpace() << " Free: " << i->getFreeSpace() << endl; } system("pause"); }

Comments
System bios info
Posted by Legacy on 02/25/2004 12:00amOriginally posted by: chetan
ReplyDll is not working with c based program
Posted by Legacy on 12/10/2003 12:00amOriginally posted by: Priya
ReplySysInfo Resolution and Multimonitor support
Posted by Legacy on 12/02/2003 12:00amOriginally posted by: Lutz Dornbusch
Hi there !
I just added support for DisplayInfo. It will give for each Monitor the MonitorHandle, HDC, Xres, Yres, bitplanes, and the Virtual Screencoords. It is running on all windows Versions down to Win95A(which do not even have MultiMonitor support)
Paul Wendt: Are you interested in this code? I have seen, you have your own DisplayInfo-class in your code, but it is commented out. I only looked briefly over the code and it examines other aspects of display(more driver specific, I think..)
Anyway thanx for this cool tool!
Greetings,
Lutz
-
Replyhow many monitors are attatched with a syatem
Posted by atif_ilm on 06/21/2004 02:29amI am looking for some piece of code which could telll me , how many monitors are attatched with a syatem , means detecting of multimonitor support. so can anybody help me.
ReplyOriginal Language of OS .?
Posted by Legacy on 11/25/2003 12:00amOriginally posted by: Dillip
Hi.,
How to determine the Original Language(no Locale) of the Operating System .?
Thanks in Advance!
Cheers,
ReplyDILLIP.
How about the platform with multiple CPUs?
Posted by Legacy on 10/15/2003 12:00amOriginally posted by: Welinn
Thanks, have a question.
ReplySome server systems have dual or more CPUs. How could I get all the information (ID, speed...) of bundled CPUs?
Can it work in dos?
Posted by Legacy on 10/07/2003 12:00amOriginally posted by: Joe
What do I need to do in order to get this or any other c++ program for that matter to run in DOS?
Reply
Very Gooooood?~!
Posted by Legacy on 10/06/2003 12:00amOriginally posted by: Thank u~!?
Good I find IT!~~!
Reply
System Info
Posted by Legacy on 09/29/2003 12:00amOriginally posted by: M. kashif Iqbal
ReplySysinfo
Posted by Legacy on 09/17/2003 12:00amOriginally posted by: sdaga
how to access std::string variables or get the value of
ReplysysInfo.getTotalRam() as an string?
Request: CPU Usage
Posted by Legacy on 09/09/2003 12:00amOriginally posted by: Daniel Berger
I would love to see some CPU usage information added. Thanks for a very handy bit of software btw!
ReplyLoading, Please Wait ...