[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Detecting hardware?

How can i detect the type (name) of my mouse, keyboard, display, CPU and computer?
0
titok
Asked:
titok
1 Solution
 
tech01Commented:
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
 
rammsteinCommented:
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

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now