topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Sunday December 15, 2024, 11:01 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: System Information Tool... im stuck...  (Read 10571 times)

Codebyte

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 160
  • "Premature Optimization is the root of all evil."
    • View Profile
    • CodeByter.com
    • Donate to Member
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:

Code: C [Select]
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Unit1.h"
  7. #include "shellapi.h"
  8. #include "stdlib.h"
  9. #include "stdio.h"
  10. #include "windows.h"
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma resource "*.dfm"
  14. TForm1 *Form1;
  15. bool WindowsVersion(char *os, char *version, char *other);
  16. int ProcessorInfo(bool NT, char *processor);
  17. //---------------------------------------------------------------------------
  18. __fastcall TForm1::TForm1(TComponent* Owner)
  19.         : TForm(Owner)
  20. {
  21. }
  22. //---------------------------------------------------------------------------
  23. bool WindowsVersion( char *os, char *version, char *other)
  24. {
  25.         bool NT = false;
  26.         OSVERSIONINFO version_info;
  27.         version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  28.         GetVersionEx(&version_info);
  29.  
  30.         if(version_info.dwMajorVersion < 4)
  31.         {
  32.                 sprintf(os, "Windows NT ");
  33.                 sprintf(version, "3.x");
  34.         }
  35.         else
  36.         {
  37.                 sprintf(version, "%d.%d.%04d", version_info.dwMajorVersion, version_info.dwMinorVersion, version_info.dwBuildNumber);
  38.         }
  39.         switch(version_info.dwPlatformId)
  40.         {
  41.                 case VER_PLATFORM_WIN32s:
  42.                   sprintf(os, "%s", "Microsoft Win32s");
  43.                   break;
  44.                 case VER_PLATFORM_WIN32_WINDOWS:
  45.                   sprintf(os, "%s", "Microsoft Windows 95/98");
  46.                   break;
  47.                 case VER_PLATFORM_WIN32_NT:
  48.                   NT = true;
  49.                   switch(version_info.dwMajorVersion)
  50.                   {
  51.                           case 4: sprintf(os, "%s", "Microsoft Windows NT"); break;
  52.                           case 5: sprintf(os, "%s", "Microsoft Windows 2000"); break;
  53.                           case 6: sprintf(os, "%s", "Microsoft Windows XP"); break;
  54.                           default :
  55.                                 sprintf(os, "%s", "Microsoft Windows ??");
  56.                   }
  57.                   break;
  58.                 default :
  59.                   sprintf(os, "%s", "Microsoft Windows ??");
  60.         }
  61.         sprintf(os, "%s", version_info.szCSDVersion);
  62.         return NT;
  63. }
  64. //---------------------------------------------------------------------------
  65. int ProcessorInfo(bool NT, char *processor)
  66. {
  67.         SYSTEM_INFO sys_info;
  68.  
  69.         AnsiString Processor;
  70.         AnsiString Level;
  71.         GetSystemInfo(&sys_info);
  72.         int value;
  73.         if(NT == true)
  74.         {
  75.                 switch(sys_info.wProcessorArchitecture)
  76.                 {
  77.                         case PROCESSOR_ARCHITECTURE_INTEL :
  78.                                 Processor = "Intel";
  79.                                 switch(sys_info.wProcessorLevel)
  80.                                 {
  81.                                         case 3 : Level = "80386";break;
  82.                                         case 4 : Level = "80486";break;
  83.                                         case 5 : Level = "Pentium"; break;
  84.                                         case 6 :
  85.                                                 value = HIBYTE(sys_info.wProcessorRevision);
  86.                                                 ShowMessage(value);
  87.                                                 switch(value)
  88.                                                 {
  89.                                                         case 1 : Level = "Pentium PRO";
  90.                                                                 Form1->Shape1->Brush->Color = clRed;
  91.                                                                 Form1->Label17->Caption = "LOW";
  92.                                                                 break;
  93.                                                         case 3,5 : Level = "Pentium II";
  94.                                                                 Form1->Shape1->Brush->Color = clRed;
  95.                                                                 Form1->Label17->Caption = "LOW";
  96.                                                                 break;
  97.                                                         case 6 : Level = "Celeron";
  98.                                                                 Form1->Shape1->Brush->Color = clRed;
  99.                                                                 Form1->Label17->Caption = "LOW";
  100.                                                                 break;
  101.                                                         case 7,8,10,11 : Level = "Pentium III";
  102.                                                                 Form1->Shape1->Brush->Color = clYellow;
  103.                                                                 Form1->Label17->Caption = "MEDIUM";
  104.                                                                 break;
  105.                                                 }
  106.                                                 break;
  107.                                         case 15 : Level = "Pentium 4";
  108.                                                 Form1->Shape1->Brush->Color = clGreen;
  109.                                                 Form1->Label17->Caption = "HIGH";
  110.                                                 break;
  111.                                         default : Level = "Unknown";
  112.                                 }
  113.                                 break;
  114.                 }
  115.         }
  116.         else //win 9x
  117.         {
  118.                 switch(sys_info.dwProcessorType)
  119.                 {
  120.                         case PROCESSOR_INTEL_386 :
  121.                                 Processor = "Intel"; Level = "80386"; break;
  122.                         case PROCESSOR_INTEL_486 :
  123.                                 Processor = "Intel"; Level = "80486"; break;
  124.                         case PROCESSOR_INTEL_PENTIUM :
  125.                                 Processor = "Intel"; Level = "Pentium"; break;
  126.                         default : Processor = "N/A";
  127.                 }
  128.         }
  129.  
  130.         sprintf(processor, "%s %s", Processor.c_str(), Level.c_str());
  131.         return sys_info.dwNumberOfProcessors;
  132. }
  133. //---------------------------------------------------------------------------
  134. void __fastcall TForm1::BitBtn1Click(TObject *Sender)
  135. {
  136.   Application->Terminate();    
  137. }
  138. //---------------------------------------------------------------------------
  139. void __fastcall TForm1::FormCreate(TObject *Sender)
  140. {
  141.    //Populate the Form
  142.    //Get User
  143.    char name[255];
  144.    DWORD size = 255;
  145.    GetUserName(name, &size);  //Win32 API Call
  146.    Label2->Caption = AnsiString(name);
  147.  
  148.    //Get OS Version
  149.    char os[255];
  150.    char version[255];
  151.    char patch[255];
  152.    bool NT = WindowsVersion(os, version, patch); //Win32 API Wrapper
  153.    Label4->Caption = AnsiString(os);
  154.    Label6->Caption = AnsiString(version);
  155.  
  156.    //get the Processor Information
  157.    char processor[MAX_PATH];
  158.    Label12->Caption = ProcessorInfo(NT, processor);
  159.    Label10->Caption = AnsiString(processor);
  160.  
  161.    //Get Memory Now
  162.    MEMORYSTATUS memory;
  163.    memory.dwLength = sizeof(memory);
  164.    GlobalMemoryStatus(&memory);
  165.  
  166.    Label14->Caption = IntToStr((memory.dwTotalPhys/1024)/1024)+" KB";
  167.  
  168.    //Get HDD Space
  169.    AnsiString Drive = AnsiString("C:\\");
  170.    DWORD spc = 0;
  171.    DWORD bps = 0;
  172.    DWORD cluster = 0;
  173.    DWORD freecluster = 0;
  174.    GetDiskFreeSpace(Drive.c_str(), &spc, &bps, &freecluster, &cluster);
  175.    unsigned long v1 = (unsigned long)cluster;
  176.    unsigned long v2 = (unsigned long)spc;
  177.    unsigned long v3 = (unsigned long)bps;
  178.    unsigned long volsize = (v1 * v2)/1024 * v3;
  179.    String vol = (volsize/1024);
  180.    vol = vol.SubString(0,2);
  181.  
  182.    if(volsize > 0)
  183.    {
  184.            Label16->Caption = IntToStr((volsize/1024)/1024) + "." + vol + " GB";
  185.    }
  186.    else
  187.    {
  188.            Label16->Caption = "n/a";
  189.    }   
  190. }
  191. //---------------------------------------------------------------------------

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..
CodeByter.com - http://www.codebyter.com
« Last Edit: June 04, 2008, 01:29 PM by Codebyte »

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,045
    • View Profile
    • Donate to Member
Re: System Information Tool... im stuck...
« Reply #1 on: June 04, 2008, 06:35 PM »
I also am a tech for a school district with about 250 computers to manage.  I currently use Belarc Advisor to give me this information.  The only problem with Belarc is it won't tell me the specs on the RAM, such as PC3200 or DDR266, etc..  Sometimes it doesn't always give the correct info for the motherboard model but most of time it does.

But I would also be interested in your app or a similar one when you get it working correctly. 

Dave

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,939
    • View Profile
    • Donate to Member
Re: System Information Tool... im stuck...
« Reply #2 on: June 04, 2008, 07:15 PM »
You can try SpiceWorks Desktop http://www.spiceworks.com/...Install it on one system only and it will hunt down a lot specs from all the computers it can reach through the local network. SpiceWorks has a nice web-based interface, is agent-less and very simple to setup.

Two screenshots:

Clipboard Image.png

and


steeladept

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,061
    • View Profile
    • Donate to Member
Re: System Information Tool... im stuck...
« Reply #3 on: June 04, 2008, 07:21 PM »
Personnally, I would suggest you just get Astra32 instead.  It is occasionally found on Giveawayoftheday (that is how I got it) and it is great.  The part that makes it most useful to you would be that it not only provides a report like Belarc, but it also formats it into a variety of report formats.  You can then use other software to do searches as you desire.  For example, you can export your report to XML and then use a small program to query against the XML.  You could also export it to CSV then import the CSV file into Excel and use the formatting in Excel.  That is just two ways to use it.  Lastly, it seems to me that there is a way to get it to report on all machines in a network if the user account has administrative access to them all, but I can't seem to find that anymore.  None the less, this is a tool that will already do what you are looking for on each computer.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: System Information Tool... im stuck...
« Reply #4 on: June 04, 2008, 07:28 PM »
Codebyte,  no one is really giving you good programming help.  You might search CodeProject for some code.

Also you say:
EDIT: Forgot to mention im coding this with CodeGear C++ Builder 2007..
There are a few good system-information components for Delphi/C++ Builder that you might look into.

steeladept

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,061
    • View Profile
    • Donate to Member
Re: System Information Tool... im stuck...
« Reply #5 on: June 04, 2008, 07:40 PM »
Codebyte,  no one is really giving you good programming help.  You might search CodeProject for some code.

True.  Sorry, but I am not a coder, though sometimes I pretend to be a scripter of sorts.  Just thought you may find a tool that would allow you to capture your intended information and your code would be geared more toward compiling it.  Just a thought...

techidave

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,045
    • View Profile
    • Donate to Member
Re: System Information Tool... im stuck...
« Reply #6 on: June 04, 2008, 08:00 PM »
I am not a coder either but was just trying to provide another tool to do a similar thing.

Sorry,
Dave

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: System Information Tool... im stuck...
« Reply #7 on: June 04, 2008, 08:28 PM »
The other suggestions were all good, i wasn't knocking them -- just trying to address Codebyte's original question.

Codebyte

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 160
  • "Premature Optimization is the root of all evil."
    • View Profile
    • CodeByter.com
    • Donate to Member
Re: System Information Tool... im stuck...
« Reply #8 on: June 04, 2008, 08:33 PM »
u guys rock! thanks alot! Im actually gonna try all of these out... I wanted to write a small app just for fun and get the experience in! I'll post later with the outcome! Thanks again!
CodeByter.com - http://www.codebyter.com

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,939
    • View Profile
    • Donate to Member
Re: System Information Tool... im stuck...
« Reply #9 on: June 05, 2008, 09:25 PM »
Ofcourse we rock!!!  (see my hairdo?   ;D)