Solved

Detecting hardware?

Posted on 1997-08-13
2
253 Views
Last Modified: 2010-04-06
How can i detect the type (name) of my mouse, keyboard, display, CPU and computer?
0
Comment
Question by:titok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:tech01
ID: 1341310
It'll Some Help To you... It can Find

Cpu's Type & Memory Size & Video Resolutions... & Etc...

If You Want To Find Some HardWare then U Must Know about

Registry & How U can Explorer Win 95's Registry...

Thanks...


unit Mr_Ahn_t_MySystemInformation;

interface

uses
   SysUtils, Windows, Classes, Mr_Ahn_classes, Registry,Forms;

type
   TMr_Ahn_RegIniFile = class(TRegIniFile)
   public
      constructor Create(const FileName: string; StartKey: HKEY);
   end;
   t_MySystemInformation = class(TComponent)
   private
      FOrganisation : string;
      FOwner : string;
      fabout : TAboutComponent;
      FPrgDir,Fsysdir : string;
      FCPU : string;
      FSH,FSW : String;
      FOperatingSystem : string;
      FWinVersion : string;
      FBuild : string;
      FTotalMemory : string;
      FDriveC : string;
      funame,fcname : string;
      procedure SetOrganisation(Value : string);
      procedure SetOwner(Value : string);
      procedure SetCPU(Value : string);
      procedure SetOperatingSystem(Value : string);
      procedure SetWinVersion(Value : string);
      procedure SetBuild(Value : string);
      procedure SetTotalMemory(Value : string);
      procedure SetDriveC(Value : string);
      procedure Setprgdir(Value : string);
      procedure Setsysdir(Value : string);
      procedure SetCname(Value : string);
      procedure SetUName(Value : string);
      function GetUName:String;
      function GetCName:String;
   protected
   public
      constructor Create(AOwner:TComponent);override;
      destructor Destroy;override;
   published
      property AboutComponent : TAboutComponent read fabout write fabout stored true;
      Property Organisation : string read FOrganisation write SetOrganisation;
      Property Owner : string read FOwner write SetOwner;
      Property CPU : string read FCPU write SetCPU;
      Property OS : string read FOperatingSystem write SetOperatingSystem;
      Property WinVersion : string read FWinVersion write SetWinVersion;
      Property Build : string read FBuild write SetBuild;
      Property TotalMemory : string read FTotalMemory write SetTotalMemory;
      Property DriveC : string read FDriveC write SetDriveC;
      Property ProgramFilesDir : String read fprgdir write Setprgdir;
      Property SystemRoot : String read fsysdir write Setsysdir;
      Property Username : String read GetUName write SetUName;
      Property ComputerName : String read GetCName write SetCname;
      Property ScreenWidth : String read fsw write SetCName;
      Property ScreenHeight : String read fsh write SetCName;
end;

implementation

constructor TMr_Ahn_RegIniFile.Create(const FileName: string; StartKey: HKEY);
begin
   RootKey := StartKey;
   LazyWrite := True;
   OpenKey(FileName, True);
end;


constructor t_MySystemInformation.Create(AOwner:TComponent);
var
   RegIni : TMr_Ahn_RegIniFile;
   SI : t_MySystemInfo;
   OS : TOSVersionInfo;
   MemStat : TMemoryStatus;
begin
   inherited Create(AOwner);
   RegIni := TMr_Ahn_RegIniFile.Create('\SOFTWARE\Microsoft\Windows', HKEY_LOCAL_MACHINE);
   FOrganisation := RegIni.ReadString('CurrentVersion', 'RegisteredOrganization', 'Failure');
   FOwner := RegIni.ReadString('CurrentVersion', 'RegisteredOwner', 'Failure');
   Fprgdir := RegIni.ReadString('CurrentVersion', 'ProgramFilesDir', 'Failure');
   Fsysdir := RegIni.ReadString('CurrentVersion', 'SystemRoot', 'Failure');
   RegIni.Free;

   Get_MySystemInfo(SI);
   case Si.dwProcessorType of
      386 : FCPU := 'Intel 386';
      486 : FCPU := 'Intel 486';
      586 : FCPU := 'Intel Pentium';
   end;

   OS.dwOSVersionInfoSize := sizeof(TOSVERSIONINFO);
   GetVersionEx(OS);
   case OS.dwPlatformId of
      VER_PLATFORM_WIN32s        : FOperatingSystem := 'Windows 3.1';
      VER_PLATFORM_WIN32_WINDOWS : FOperatingSystem := 'Windows 95';
      VER_PLATFORM_WIN32_NT       : FOperatingSystem := 'Windows NT';
   end;

   FWinVersion := format ('%d.%d', [OS.dwMajorVersion,OS.dwMinorVersion]);
   FBuild := format('%d', [LOWORD(OS.dwBuildNumber)]);

   MemStat.dwLength := sizeof(TMemoryStatus);
   GlobalMemoryStatus(MemStat);
   FTotalMemory := format('%d KB',[Trunc(MemStat.dwTotalPhys/1024)]);
   if DiskSize(3) <> -1 then
      FDriveC := format('%d MB', [Trunc(DiskSize(3)/1024/1024)])
   else
      FDriveC := '';
  fabout:=TAboutComponent.create(Self);
  fabout.check;
  fsh:=Inttostr(Screen.height);
  fsw:=Inttostr(Screen.width);
end;


function t_MySystemInformation.GetUName:String;
Var
  lpBuffer: lpstr;
  success: Boolean;
  nSize: DWord;
Begin
  nSize := 255;
  Result := '';
  GetMem(lpBuffer, 255);
  try
    success := GetUserName(lpBuffer, nSize);
    if (not success) then result:='Error on locating Username';
    Result := StrPas(lpBuffer);
    FUName:= StrPas(lpBuffer);
  finally
    FreeMem(lpBuffer);
  end;
End;

function t_MySystemInformation.GetCName:String;
Var
  lpBuffer: lpstr;
  success: Boolean;
  nSize: DWord;
Begin
  nSize := 255;
  Result := '';
  GetMem(lpBuffer, 255);
  try
    success := GetComputerName(lpBuffer, nSize);
    if (not success) then result:='Error on locating Computername';
    result := StrPas(lpBuffer);
    fCName := StrPas(lpBuffer);
  finally
    FreeMem(lpBuffer);
  end;
End;


destructor t_MySystemInformation.Destroy;
begin
  fabout.free;
  inherited Destroy;
end;

procedure t_MySystemInformation.SetOrganisation(Value : string);
begin
   FOrganisation := FOrganisation;
end;

procedure t_MySystemInformation.SetUName(Value : string);
begin
   FUname:=FUname;
end;

procedure t_MySystemInformation.SetCName(Value : string);
begin
   FCname:=FCname;
   fsh:=Inttostr(Screen.height);
   fsw:=Inttostr(Screen.width);
end;


procedure t_MySystemInformation.SetOwner(Value : string);
begin
   FOwner := FOwner;
end;

procedure t_MySystemInformation.SetCPU(Value : string);
begin
   FCPU := FCPU;
end;

procedure t_MySystemInformation.SetOperatingSystem(Value : string);
begin
   FOperatingSystem := FOperatingSystem;
end;

procedure t_MySystemInformation.SetWinVersion(Value : string);
begin
   FWinVersion := FWinVersion;
end;

procedure t_MySystemInformation.SetBuild(Value : string);
begin
   FBuild := FBuild;
end;

procedure t_MySystemInformation.SetTotalMemory(Value : string);
begin
   FTotalMemory := FTotalmemory;
end;

procedure t_MySystemInformation.SetDriveC(Value : string);
begin
   FDriveC := FDriveC;
end;

procedure t_MySystemInformation.Setprgdir(Value : string);
begin
   Fprgdir := Fprgdir;
end;

procedure t_MySystemInformation.Setsysdir(Value : string);
begin
   Fsysdir := Fsysdir;
end;

end.
0
 

Accepted Solution

by:
rammstein earned 100 total points
ID: 1341311
unit sysinfo;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Math;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    CPUValue: TLabel;
    Mouse: TLabel;
    MouseValue: TLabel;
    Computer: TLabel;
    Computervalue: TLabel;
    keyboard: TLabel;
    KeyboardValue: TLabel;
    Dresolution: TLabel;
    Resolution: TLabel;
    InfoButton: TButton;
    DColors: TLabel;
    NumColors: TLabel;
    procedure InfoButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.InfoButtonClick(Sender: TObject);
var cpu : string;
    sysinfo:TSysteminfo;
    cname, keybname: PChar;
    cnsize, keybsize: DWord;
    dc: hDC;
begin
Getsysteminfo(sysinfo);
(*CPU*)
case sysinfo.dwprocessortype of
386: cpu:='Intel 386er';
486: cpu:='Intel 486er';
586: cpu:='Intel Pentium';
860: cpu:='Intel 860';
2000: cpu:='MIPS 2000';
3000: cpu:='MIPS 3000';
4000: cpu:='MIPS 4000';
21064: cpu:='MIPS 21064';
601: cpu:='PPC 601';
603: cpu:='PPC 603';
604: cpu:='PPC 604';
620: cpu:='PPC 620';
end;
cpuvalue.caption:=cpu;
(*Mouse*) // is it this info you wanted to have about the mouse :)
if (windows.GetSystemMetrics(SM_MOUSEPRESENT)>0) then
Mousevalue.Caption:='Present'
else
Mousevalue.Caption:='Absent';
(*Computername*)
cnsize:=MAX_COMPUTERNAME_LENGTH+1;
cname:=stralloc(cnsize);
windows.getcomputernamea(cname,cnsize);
computervalue.caption:=cname;
strdispose(cname);
(*Keyboardlayout*)
keybsize:=KL_NAMELENGTH+1;
keybname:=stralloc(keybsize);
windows.GetKeyboardLayoutName(keybname);
Keyboardvalue.caption:=keybname; // actually returns a hex-value
                                 // which is the language-identifier
strdispose(keybname);
(*Display*)
Resolution.caption:=Inttostr(screen.width)+'x'+inttostr(screen.height);

dc:=getdc(Handle); // I knew you'd like that :))
Numcolors.caption:=floattostr(Power(2,GetDeviceCaps(dc, BITSPIXEL)));
ReleaseDC(Handle,dc);
end;


end.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 231
Delphi...Split view - idea? 1 148
Multi-layered image in FireMonkey 9 94
Browsing a TTreeView in Delphi 5 50
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question