topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Thursday March 28, 2024, 9:13 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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Codebyte [ switch to compact view ]

Pages: prev1 [2]
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:

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..

27
Developer's Corner / Peer-2-Peer app
« on: February 26, 2008, 09:55 AM »
Alright, so I have been thinking about creating an application that can use a socket to communicate text and files and things... I have been wandering what component to use... I use the new RAD CodeGear C++ Builder... Im not to familiar with networking but all of the applications that I have been developing usually use an additional server application to do anything... Is there a socket (UDP, TCP/IP...etc) that supports these capabilities and which is the best to use? I dont want to run into errors with firewalls or anything either... What kind of work am i getting myself into? Whats the best way to go into this? Any ideas?

28
Developer's Corner / My Application...
« on: January 07, 2008, 10:25 PM »
Im using BCB 2007 to code my application for windows vista... My app connects to a declared ftp server just fine, but when it begins to download files it locks the application up until the download is done... Is there some kind of coding that I can add to allow my program to run fine?

Any help is greatly appreciated... thnx :)

29
Post New Requests Here / IDEA: Volume Controller
« on: December 30, 2007, 07:18 PM »
Here is my problem: I play alot of video games and while chatting to friends using an application such as Ventrilo. I need a program that will minimize the volume of the game and maximize the volume of Ventrilo when someone talks. It also has to be able to allow me to select the process that i want to minimize and maximize. It also needs to have an option that allows me to switch between Auto adjusting the volume and manually adjusting the volume (where i hit a global hotkey and while the hotkey is held down it keeps the volumes equal to what i set.) The program needs to fade the volume in and out so it doesnt hurt my ears as well.

30
Developer's Corner / Implementing VoIP to a simple program...
« on: November 09, 2007, 02:16 PM »
Alright, so here is what I need to do:

I moved off to college and want to program a piece of software (nothing big), that will be able to take advantage of VoIP so I can talk to my parents at home. I am familiar with Delphi/C++ but would be willing to learn something new.

Is there a component/plugin I could buy for my IDE (Borland Developer Studio 2006/2007) that allows VoIP? If so, is it cheap and efficient? If not, could I program my own component to do the job? I don't even know where to start, but I do know that I want to make this software work.

Thanks for your time,
-CodeByer

Pages: prev1 [2]