Click here to Skip to main content
15,910,130 members
Articles / Desktop Programming / MFC
Article

System Information

Rate me:
Please Sign up or sign in to vote.
4.58/5 (55 votes)
19 Aug 20032 min read 474.3K   17.9K   154   131
Obtaining Information from Computer Hardware/Software

Screen shot of program

Introduction

This program shows you a very simple way to determine your PC hardware and software. It queries operating system for the following Hardware/Software:

  • Operating System Version (Thanks to PJ Naughter)
  • Computer Name
  • IP Address of Computer
  • User Name
  • Internet Explorer Version
  • Total RAM
  • Free Memory
  • Number of Hard Disk Drives
  • Hard Disk Total Space/Free Space/Used Space
  • CDROM Drives
  • Monitor Resolution
  • Color Depth
  • Number of CPUs (Thanks to Iain Chesworth)
  • CPU Speed
  • CPU Identifier
  • CPU Vendor Identifier
  • Operating System Folder
  • System Folder

Program structure

By clicking the combo box and changing it's item, selected item is determined and it's ID passed to Process member function of dialog. The Process member function takes ID of query and returns the proper result. Body of Process has a lot of code to prepares result and if any error has occurred, the error string will be returned.

How to use

Add the following header and implementation files to your project:
  • cup_info.h, cpu_info.cpp: For CPU Information like Speed, ID, Vendor ID,...
  • dtwinver.h, dtwinver.cpp: For Operating System Version (e.g. Build Number and Service Packs)
  • SysInfoDefs.h, SysInfoDefs.cpp: For General System Information like Total RAM, Number of Hard Disk Drives, Disk Space/Free Space/Used Space
  • SmartDef.h: For IDE S.M.A.R.T. commands to query from IDE hard disks that support SMART.

Functions

Below table shows all functions that are used to determine Hardware/Software of the computer.

CString DetermineIEVer();Determining Internet Explorer Version (Build Number)
CString QueryHardDisks();Calculating Number of Hard Disks and Number of Cylinders, Tracks per Cylinders, Sectors per Tracks, Bytes per Sector and Total Capacity for each Hard Disks
CString QueryDriveSpace();Calculating Drive Space/Free Space/Used Space of All Hard Drives
CString QueryCDDrive();Determining Number of CD Drives
CString QueryTotalRAM()Calculating Total Physical RAM (Random Access Memory)
CString QueryFreeRAM();Calculating Free Physical Memory
CString QueryUserName()User Name of current user
CString QueryComputerName();Computer Name
CString QueryCPUInfo();Number of CPU Installed on Mother Board
CString QueryCPUSpeed();Speed of each CPU
CString QueryCPUID();ID of each CPU
CString QueryCPUVendorID();ID of CPU Vendor
CString QueryResolution();Calculating Monitor Resolution in Pixel
CString QueryPixelDepth();Calculating Color Depth of any Pixel
CString QueryOS();Determining Operating System Version (Build Number) and it's Service Pack
CString QueryLocalIPAddress();Determining IP Address of Computer
CString QueryHDDSmartCommand();Query IDE hard disks that support SMART (Self-Monitoring Analysis & Reporting Technology).
CString QueryDirectory(char* sFolder,int iFolder);Determining Full Path of Specified Folder where sFolder is Folder Name and iFolder is Folder Shell ID Number
CString GetCommandError();Determining last occurred error

Requirements

  • Latest Platform SDK
  • Visual Studio 6.0 with service pack 5

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
CEO Solaris Electronics LLC
United Arab Emirates United Arab Emirates
I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acquisition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competition, my articles are:


You can see list of my articles, by clicking here


Comments and Discussions

 
GeneralNice! Pin
yingyuheng5-Jan-03 3:29
yingyuheng5-Jan-03 3:29 
GeneralMissing header file Pin
Jon Burgstrom4-Jan-03 22:40
Jon Burgstrom4-Jan-03 22:40 
GeneralRe: Missing header file Pin
Abbas_Riazi4-Jan-03 23:12
professionalAbbas_Riazi4-Jan-03 23:12 
GeneralRe: Missing header file Pin
Victor Boctor5-Jan-03 13:14
Victor Boctor5-Jan-03 13:14 
GeneralRe: Missing header file Pin
George Anescu6-Jan-03 3:53
George Anescu6-Jan-03 3:53 
GeneralRe: Missing header file Pin
Abbas_Riazi6-Jan-03 6:10
professionalAbbas_Riazi6-Jan-03 6:10 
GeneralRe: Missing header file Pin
Didaa7-Jan-03 2:19
Didaa7-Jan-03 2:19 
GeneralRe: Missing header file Pin
lixding15-Feb-03 5:56
lixding15-Feb-03 5:56 
This is my way. I have had the file SysInfo.exe.
You can create the file. the filename is OXVerInfo.h
Context is follow:

//--------------OXVerInfo.h----------------------//
//Create date:2003-02-15 //
//Designer: lixding@dnc.hit.edu.cn //
//-----------------------------------------------//
/*
The content was downloaded from
url://http://www.wac-jp.com/programmers/win32/GetSpecialFolder.shtml
*/
#define CSIDL_DESKTOP 0x0000 // <desktop>
#define CSIDL_INTERNET 0x0001 // Internet Explorer (icon on desktop)

#define CSIDL_PROGRAMS 0x0002 // Start Menu\Programs
#define CSIDL_CONTROLS 0x0003 // My Computer\Control Panel
#define CSIDL_PRINTERS 0x0004 // My Computer\Printers
#define CSIDL_PERSONAL 0x0005 // My Documents
#define CSIDL_FAVORITES 0x0006 // <user name>\Favorites
#define CSIDL_STARTUP 0x0007 // Start Menu\Programs\Startup
#define CSIDL_RECENT 0x0008 // <user name>\Recent
#define CSIDL_SENDTO 0x0009 // <user name>\SendTo
#define CSIDL_BITBUCKET 0x000a // <desktop>\Recycle Bin
#define CSIDL_STARTMENU 0x000b // <user name>\Start Menu
#define CSIDL_MYDOCUMENTS 0x000c // logical "My Documents" desktop icon
#define CSIDL_MYMUSIC 0x000d // "My Music" folder
#define CSIDL_MYVIDEO 0x000e // "My Videos" folder
#define CSIDL_DESKTOPDIRECTORY 0x0010 // <user name>\Desktop
#define CSIDL_DRIVES 0x0011 // My Computer
#define CSIDL_NETWORK 0x0012 // Network Neighborhood
#define CSIDL_NETHOOD 0x0013 // <user name>\nethood
#define CSIDL_FONTS 0x0014 // windows\fonts
#define CSIDL_TEMPLATES 0x0015
#define CSIDL_COMMON_STARTMENU 0x0016 // All Users\Start Menu
#define CSIDL_COMMON_PROGRAMS 0X0017 // All Users\Start Menu\Programs
#define CSIDL_COMMON_STARTUP 0x0018 // All Users\Startup
#define CSIDL_COMMON_DESKTOPDIRECTORY 0x0019 // All Users\Desktop
#define CSIDL_APPDATA 0x001a // <user name>\Application Data
#define CSIDL_PRINTHOOD 0x001b // <user name>\PrintHood
#define CSIDL_LOCAL_APPDATA 0x001c
// <user name>\Local Settings\Applicaiton Data (non roaming)
#define CSIDL_ALTSTARTUP 0x001d // non localized startup
#define CSIDL_COMMON_ALTSTARTUP 0x001e // non localized common startup
#define CSIDL_COMMON_FAVORITES 0x001f
#define CSIDL_INTERNET_CACHE 0x0020
#define CSIDL_COOKIES 0x0021
#define CSIDL_HISTORY 0x0022
#define CSIDL_COMMON_APPDATA 0x0023 // All Users\Application Data
#define CSIDL_WINDOWS 0x0024 // GetWindowsDirectory()
#define CSIDL_SYSTEM 0x0025 // GetSystemDirectory()
#define CSIDL_PROGRAM_FILES 0x0026 // C:\Program Files
#define CSIDL_MYPICTURES 0x0027 // C:\Program Files\My Pictures
#define CSIDL_PROFILE 0x0028 // USERPROFILE
#define CSIDL_SYSTEMX86 0x0029 // x86 system directory on RISC
#define CSIDL_PROGRAM_FILESX86 0x002a // x86 C:\Program Files on RISC
#define CSIDL_PROGRAM_FILES_COMMON 0x002b // C:\Program Files\Common
#define CSIDL_PROGRAM_FILES_COMMONX86 0x002c // x86 Program Files\Common on RISC
#define CSIDL_COMMON_TEMPLATES 0x002d // All Users\Templates
#define CSIDL_COMMON_DOCUMENTS 0x002e // All Users\Documents
#define CSIDL_COMMON_ADMINTOOLS 0x002f
// All Users\Start Menu\Programs\Administrative Tools
#define CSIDL_ADMINTOOLS 0x0030
// <user name>\Start Menu\Programs\Administrative Tools
#define CSIDL_CONNECTIONS 0x0031 // Network and Dial-up Connections
#define CSIDL_COMMON_MUSIC 0x0035 // All Users\My Music
#define CSIDL_COMMON_PICTURES 0x0036 // All Users\My Pictures
#define CSIDL_COMMON_VIDEO 0x0037 // All Users\My Video
#define CSIDL_RESOURCES 0x0038 // Resource Direcotry
#define CSIDL_RESOURCES_LOCALIZED 0x0039 // Localized Resource Direcotry

#define CSIDL_FLAG_CREATE 0x8000
// combine with CSIDL_value to force folder creation in SHGetFolderPath()
#define CSIDL_FLAG_DONT_VERIFY 0x4000
// combine with CSIDL_value to return an unverified folder path
#define CSIDL_FLAG_NO_ALIAS 0x1000
// combine with CSIDL_value to insure non-alias versions of the pidl
#define CSIDL_FLAG_PER_USER_INIT 0x0800
// combine with CSIDL_value to indicate per-user init (eg. upgrade)
#define CSIDL_FLAG_MASK 0xFF00 // mask for all possible flag values
//-------------------------The End---------------------//




GeneralRe: Missing header file Pin
Abbas_Riazi15-Feb-03 7:15
professionalAbbas_Riazi15-Feb-03 7:15 
GeneralRe: Missing header file Pin
lixding16-Feb-03 16:14
lixding16-Feb-03 16:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.