26
Developer's Corner / System Information Tool... im stuck...
« on: June 04, 2008, 01:26 PM »
So, this summer my dad, who works at a Highschool as the Head Tech Coordinator, has around 150-200 computers that he needs formatted... His problem is that he doesnt want to have to pull information from each computer concerning the stats, write them down and then determine whether to keep it or not... So, I tried working on a little application that will basically collect minimal system information (specific information that he needs) concerning the hardware inside the computers... After the program collects the information, I would like it to Rate the system for me based on how new the CPU is (a.k.a using the wProcessorRevision property)... This "rating" system is still to be determined and not completely accurate... This has given my dad a headache so far and I wanna try to get this done for him as a "half-suprise..." (He's a nerd and he'll love this gift)...
My results:
I wrote some coding to see if I could do this myself... Here it is:
The problem:
-I tried using this on an Intel Pentium III and it wouldn't detect the wProcessorLevel... so the label displays "Intel" only... Doesn't make sense to me... I tried using it on several different computers and the only one that I had luck with was an Intel Pentium 4...
If you don't have time to check this out, thanks for at least reading this... I am looking up stuff right now on the internet but the only problem is that I dont actually understand what needs to be fixed here... I am thinking that something is wrong with the output... not sure tho.. Any Ideas?
EDIT: Forgot to mention im coding this with CodeGear C++ Builder 2007..
My results:
I wrote some coding to see if I could do this myself... Here it is:
Code: C [Select]
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- #include "shellapi.h"
- #include "stdlib.h"
- #include "stdio.h"
- #include "windows.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- bool WindowsVersion(char *os, char *version, char *other);
- int ProcessorInfo(bool NT, char *processor);
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- bool WindowsVersion( char *os, char *version, char *other)
- {
- bool NT = false;
- OSVERSIONINFO version_info;
- version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&version_info);
- if(version_info.dwMajorVersion < 4)
- {
- }
- else
- {
- sprintf(version, "%d.%d.%04d", version_info.dwMajorVersion, version_info.dwMinorVersion, version_info.dwBuildNumber);
- }
- switch(version_info.dwPlatformId)
- {
- case VER_PLATFORM_WIN32s:
- break;
- case VER_PLATFORM_WIN32_WINDOWS:
- break;
- case VER_PLATFORM_WIN32_NT:
- NT = true;
- switch(version_info.dwMajorVersion)
- {
- default :
- }
- break;
- default :
- }
- return NT;
- }
- //---------------------------------------------------------------------------
- int ProcessorInfo(bool NT, char *processor)
- {
- SYSTEM_INFO sys_info;
- AnsiString Processor;
- AnsiString Level;
- GetSystemInfo(&sys_info);
- int value;
- if(NT == true)
- {
- switch(sys_info.wProcessorArchitecture)
- {
- case PROCESSOR_ARCHITECTURE_INTEL :
- Processor = "Intel";
- switch(sys_info.wProcessorLevel)
- {
- case 3 : Level = "80386";break;
- case 4 : Level = "80486";break;
- case 5 : Level = "Pentium"; break;
- case 6 :
- value = HIBYTE(sys_info.wProcessorRevision);
- ShowMessage(value);
- switch(value)
- {
- case 1 : Level = "Pentium PRO";
- Form1->Shape1->Brush->Color = clRed;
- Form1->Label17->Caption = "LOW";
- break;
- case 3,5 : Level = "Pentium II";
- Form1->Shape1->Brush->Color = clRed;
- Form1->Label17->Caption = "LOW";
- break;
- case 6 : Level = "Celeron";
- Form1->Shape1->Brush->Color = clRed;
- Form1->Label17->Caption = "LOW";
- break;
- case 7,8,10,11 : Level = "Pentium III";
- Form1->Shape1->Brush->Color = clYellow;
- Form1->Label17->Caption = "MEDIUM";
- break;
- }
- break;
- case 15 : Level = "Pentium 4";
- Form1->Shape1->Brush->Color = clGreen;
- Form1->Label17->Caption = "HIGH";
- break;
- default : Level = "Unknown";
- }
- break;
- }
- }
- else //win 9x
- {
- switch(sys_info.dwProcessorType)
- {
- case PROCESSOR_INTEL_386 :
- Processor = "Intel"; Level = "80386"; break;
- case PROCESSOR_INTEL_486 :
- Processor = "Intel"; Level = "80486"; break;
- case PROCESSOR_INTEL_PENTIUM :
- Processor = "Intel"; Level = "Pentium"; break;
- default : Processor = "N/A";
- }
- }
- return sys_info.dwNumberOfProcessors;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::BitBtn1Click(TObject *Sender)
- {
- Application->Terminate();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- //Populate the Form
- //Get User
- char name[255];
- DWORD size = 255;
- GetUserName(name, &size); //Win32 API Call
- Label2->Caption = AnsiString(name);
- //Get OS Version
- char os[255];
- char version[255];
- char patch[255];
- bool NT = WindowsVersion(os, version, patch); //Win32 API Wrapper
- Label4->Caption = AnsiString(os);
- Label6->Caption = AnsiString(version);
- //get the Processor Information
- char processor[MAX_PATH];
- Label12->Caption = ProcessorInfo(NT, processor);
- Label10->Caption = AnsiString(processor);
- //Get Memory Now
- MEMORYSTATUS memory;
- memory.dwLength = sizeof(memory);
- GlobalMemoryStatus(&memory);
- Label14->Caption = IntToStr((memory.dwTotalPhys/1024)/1024)+" KB";
- //Get HDD Space
- AnsiString Drive = AnsiString("C:\\");
- DWORD spc = 0;
- DWORD bps = 0;
- DWORD cluster = 0;
- DWORD freecluster = 0;
- GetDiskFreeSpace(Drive.c_str(), &spc, &bps, &freecluster, &cluster);
- unsigned long v1 = (unsigned long)cluster;
- unsigned long v2 = (unsigned long)spc;
- unsigned long v3 = (unsigned long)bps;
- unsigned long volsize = (v1 * v2)/1024 * v3;
- String vol = (volsize/1024);
- vol = vol.SubString(0,2);
- if(volsize > 0)
- {
- Label16->Caption = IntToStr((volsize/1024)/1024) + "." + vol + " GB";
- }
- else
- {
- Label16->Caption = "n/a";
- }
- }
- //---------------------------------------------------------------------------
The problem:
-I tried using this on an Intel Pentium III and it wouldn't detect the wProcessorLevel... so the label displays "Intel" only... Doesn't make sense to me... I tried using it on several different computers and the only one that I had luck with was an Intel Pentium 4...
If you don't have time to check this out, thanks for at least reading this... I am looking up stuff right now on the internet but the only problem is that I dont actually understand what needs to be fixed here... I am thinking that something is wrong with the output... not sure tho.. Any Ideas?
EDIT: Forgot to mention im coding this with CodeGear C++ Builder 2007..