Way to Get Hardware/Programs Info?

This is a discussion on Way to Get Hardware/Programs Info? within the Windows Programming forums, part of the Platform Specific Boards category; Does anyone know any functions to get hardware information such as amount of RAM, processor speed, monitor model, and disc ...

  1. #1

    Way to Get Hardware/Programs Info?

    Does anyone know any functions to get hardware information such as amount of RAM, processor speed, monitor model, and disc space?

    Also, is there a way to get a list of programs installed?


  2. #2
    List of programs can be obtained from the registry.

    The same place where the add remove programs box gets its info
    which is HKEY_LOCAL_MACHINE/software/Microsoft/windows/CurrentVersion/Uninstall

    each key is program and you get the info from the data within the key. This should be the same on all versions of windows.

    As for the hardware I'm not sure but I've seen info on this before I'm sure someone here will know how.

    BTW for windows settings and stuff checkout www.regedit.com it has everything known about the registry almost.

    Im not linked with that site but I've found out lots of neat stuff for tweaking settings so I plug it as often as possible especially to programmers.

  3. #3
    Thanks, but I'm not quite sure how I would use that list of programs in the registry. I know I can do this:

    if(RegOpenKey() == ERROR_SUCCESS)

    but to use that I need to be searching for a specific progam.

  4. #4
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Look into RegEnumKey().
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  5. #5

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Going to the registry can be a pain as the layout of the registry changes with each platform...

    The Disk Space and memory size can be found with published APIs....

    Clock speed is a bit more problematic, but there is a key in the Windows 2000 registry which gives an indication...I cant vouch for other platforms as my 2 pcs have Win2K

    Monitor type is probably not worth looking for.....many monitors are loaded as "default monitor" as they use a default PnP driver.......therefore even if you found the name of the driver, it might not correspond to the device sat in front of you

    Anyway...here's a few ideas...

    #include <iostream>
    #include <iomanip>
    #include <cmath>
    #include <windows.h>
    using namespace std;
    int main(void){
    // First off - Memory size
    	MEMORYSTATUS ms = {0};
    	cout << "Total amount of physical memory = ";
    	cout << ms.dwTotalPhys / 1048576<< "MB" << endl;
    // Now to peek in the registry for CPU speed
    	HKEY hKey;	
    	char *lpValName = "~MHz",
    		*lpKey = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
    	DWORD dwProcSpeed,dwSize,dwType;
    		dwSize = sizeof(DWORD);
    		dwType = REG_DWORD;
    			(LPBYTE)&dwProcSpeed,&dwSize) == ERROR_SUCCESS){
    		double dProcSpeed = (double)dwProcSpeed;
    		dProcSpeed /= 100;
    		dwProcSpeed = ceil(dProcSpeed);
    		dwProcSpeed *= 100;
    			cout << "CPU speed = " << dwProcSpeed;
    			cout << "Mhz" << endl;
    		else cout << "Could not find processor speed" << endl;
    	else cout << "Could not find processor speed information" << endl;
    // Now to Get the free space
    	DWORD dwSectorsPerCluster,dwBytesPerSector,
    		double dFreeSpace = 
    			dwBytesPerSector * dwSectorsPerCluster * 
    		cout << "This disk has " << dFreeSpace / 1073741824; 
    		cout <<	"GB free" << endl;
    	else cout << "Could not find disk size information" << endl;
    	return 0;
    Last edited by Fordy; 07-16-2002 at 10:47 AM.

  7. #7



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help displaying info from structure
    By kisiellll in forum C Programming
    Replies: 6
    Last Post: 04-04-2009, 01:51 PM
  2. Question about getting an info class from another Form
    By Joelito in forum C# Programming
    Replies: 0
    Last Post: 10-16-2006, 02:02 PM
  3. Help doing an e-mail program in c...
    By Tyler_Durden in forum C Programming
    Replies: 88
    Last Post: 01-02-2005, 03:12 PM
  4. Way to Get Hardware/Programs Info?
    By Mike2432 in forum C++ Programming
    Replies: 3
    Last Post: 07-15-2002, 11:14 PM
  5. Replies: 3
    Last Post: 12-06-2001, 05:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21