home *** CD-ROM | disk | FTP | other *** search
-
- {*******************************************************}
- { }
- { MiTeC System Information Console Object }
- { version 6.0 for Delphi 5,6 }
- { }
- { Copyright ⌐ 1997,2001 Michal Mutl }
- { }
- {*******************************************************}
-
- {$INCLUDE MITEC_DEF.INC}
-
- unit MSI_Console;
-
- interface
-
- uses
- MSI_CPU, MSI_Machine, MSI_Devices, MSI_Display, MSI_Network, MSI_Media,
- MSI_Memory, MSI_Engines, MSI_APM, MSI_Disk, MSI_DirectX, MSI_OS, MSI_Processes,
- MSI_Printers, MSI_Software, MSI_Startup,
- Windows, SysUtils, Classes;
-
- const
- cCompName = 'MiTeC System Information Object';
- cVersion = '6.0';
- cCopyright = 'Copyright (c) 1997,2001 Michal Mutl';
-
- type
- TSubObject = (soCPU, soMachine, soDevices, soDisplay, soNetwork, soMedia,
- soMemory, soEngines, soAPM, soDisk, soDirectX, soOS, soProcesses,
- soPrinters, soSoftware, soStartup);
-
- TSubObjects = set of TSubObject;
-
- TExceptionMode = (emRaise, emMessage, emSilent);
-
- TGetInfo = procedure of object;
-
-
- const
- soAll = [soCPU, soMachine, soDevices, soDisplay, soNetwork, soMedia,
- soMemory, soEngines, soAPM, soDisk, soDirectX, soOS, soProcesses,
- soPrinters, soSoftware, soStartup];
-
- type
- TMSI = class(TPersistent)
- private
- FCPU: TCPU;
- FMemory: TMemory;
- FOS :TOperatingSystem;
- FDisk :TDisk;
- FMachine: TMachine;
- FNetwork: TNetwork;
- FDisplay: TDisplay;
- FEngines: TEngines;
- FDevices: TDevices;
- FAPM :TAPM;
- FAbout: string;
- FDirectX: TDirectX;
- FMedia: TMedia;
- FProcesses: TProcesses;
- FPrinters: TPrinters;
- FSoftware: TSoftware;
- FStartup: TStartup;
- FMode: TExceptionMode;
- public
- constructor Create(ASubObjects: TSubObjects = soAll);
- destructor Destroy; override;
- procedure Refresh;
- procedure Report(var sl :TStringList);
-
- property About :string read FAbout;
- property ExceptionMode: TExceptionMode read FMode write FMode;
- property CPU :TCPU read FCPU;
- property Memory :TMemory read FMemory;
- property OS :TOperatingSystem read FOS;
- property Disk :TDisk read FDisk;
- property Machine :TMachine read FMachine;
- property Network :TNetwork read FNetwork;
- property Display :TDisplay read FDisplay;
- property Media :TMedia read FMedia;
- property Devices :TDevices read FDevices;
- property Engines :TEngines read FEngines;
- property APM :TAPM read FAPM;
- property DirectX :TDirectX read FDirectX;
- property Processes :TProcesses read FProcesses;
- property Printers :TPrinters read FPrinters;
- property Software :TSoftware read FSoftware;
- property Startup: TStartup read FStartup;
- end;
-
- implementation
-
- uses MiTeC_Routines;
-
- procedure MSafeCall(Func: TGetInfo; Description: string; Mode: TExceptionMode);
- begin
- try
- Func;
- except
- on e: exception do begin
- case Mode of
- emRaise: raise Exception.Create(Description+': '+e.message);
- emMessage: if IsConsole then
- writeln(Description+': '+e.message)
- else
- MessageBox(0,PChar(Description+': '+e.message),'Error',MB_OK or MB_ICONERROR);
- emSilent: ;
- end;
- end;
- end;
- end;
-
- { TMSI }
-
- constructor TMSI.Create;
- begin
- FAbout:=cCompName+' '+cVersion+' - '+cCopyright;
- FMode:=emMessage;
- if soCPU in ASubObjects then
- FCPU:=TCPU.Create;
- if soMemory in ASubObjects then
- FMemory:=TMemory.Create;
- if soOS in ASubObjects then
- FOS:=TOperatingSystem.Create;
- if soDisk in ASubObjects then
- FDisk:=TDisk.Create;
- if soMachine in ASubObjects then
- FMachine:=TMachine.Create;
- if soNetwork in ASubObjects then
- FNetwork:=TNetwork.Create;
- if soDisplay in ASubObjects then
- FDisplay:=TDisplay.Create;
- if soMedia in ASubObjects then
- FMedia:=TMedia.Create;
- if soDevices in ASubObjects then
- FDevices:=TDevices.Create;
- if soEngines in ASubObjects then
- FEngines:=TEngines.Create;
- if soAPM in ASubObjects then
- FAPM:=TAPM.Create;
- if soDirectX in ASubObjects then
- FDirectX:=TDirectX.Create;
- if soProcesses in ASubObjects then
- FProcesses:=TProcesses.Create;
- if soPrinters in ASubObjects then
- FPrinters:=TPrinters.Create;
- if soSoftware in ASubObjects then
- FSoftware:=TSoftware.Create;
- if soStartup in ASubObjects then
- FStartup:=TStartup.Create;
- end;
-
- destructor TMSI.Destroy;
- begin
- if Assigned(FCPU) then
- FCPU.Free;
- if Assigned(FMemory) then
- FMemory.Free;
- if Assigned(FOS) then
- FOS.Free;
- if Assigned(FDisk) then
- FDisk.Free;
- if Assigned(FMachine) then
- FMachine.Free;
- if Assigned(FNetwork) then
- FNetwork.Free;
- if Assigned(FDisplay) then
- FDisplay.Free;
- if Assigned(FMedia) then
- FMedia.Free;
- if Assigned(FDevices) then
- FDevices.Free;
- if Assigned(FEngines) then
- FEngines.Free;
- if Assigned(FAPM) then
- FAPM.Free;
- if Assigned(FDirectX) then
- FDirectX.Free;
- if Assigned(FProcesses) then
- FProcesses.Free;
- if Assigned(FPrinters) then
- FPrinters.Free;
- if Assigned(FSoftware) then
- FSoftware.Free;
- if Assigned(FStartup) then
- FStartup.Free;
- inherited;
- end;
-
- procedure TMSI.Refresh;
- begin
- if Assigned(Devices) then
- MSafeCall(Devices.GetInfo,Devices.Classname+'.GetInfo',ExceptionMode);
- if Assigned(CPU) then
- MSafeCall(CPU.GetInfo,CPU.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Memory) then
- MSafeCall(Memory.GetInfo,Memory.Classname+'.GetInfo',ExceptionMode);
- if Assigned(OS) then
- MSafeCall(OS.GetInfo,OS.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Disk) then begin
- MSafeCall(Disk.GetInfo,Disk.Classname+'.GetInfo',ExceptionMode);
- Disk.Drive:=ExtractFileDrive(GetWinDir);
- end;
- if Assigned(Machine) then
- MSafeCall(Machine.GetInfo,Machine.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Network) then
- MSafeCall(Network.GetInfo,Network.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Display) then
- MSafeCall(Display.GetInfo,Display.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Media) then
- MSafeCall(Media.GetInfo,Media.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Engines) then
- MSafeCall(Engines.GetInfo,Engines.Classname+'.GetInfo',ExceptionMode);
- if Assigned(APM) then
- MSafeCall(APM.GetInfo,APM.Classname+'.GetInfo',ExceptionMode);
- if Assigned(DirectX) then
- MSafeCall(DirectX.GetInfo,DirectX.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Processes) then
- MSafeCall(Processes.GetInfo,Processes.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Printers) then
- MSafeCall(Printers.GetInfo,Printers.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Software) then
- MSafeCall(Software.GetInfo,Software.Classname+'.GetInfo',ExceptionMode);
- if Assigned(Startup) then
- MSafeCall(Startup.GetInfo,Startup.Classname+'.GetInfo',ExceptionMode);
- end;
-
- procedure TMSI.Report(var sl: TStringList);
- begin
- sl.add('; '+About);
- sl.add('');
- if Assigned(FMachine) then
- Machine.Report(sl);
- if Assigned(FOS) then
- OS.Report(sl);
- if Assigned(FCPU) then
- CPU.Report(sl);
- if Assigned(Fmemory) then
- Memory.Report(sl);
- if Assigned(FDisplay) then
- Display.Report(sl);
- if Assigned(FAPM) then
- APM.Report(sl);
- if Assigned(FMedia) then
- Media.Report(sl);
- if Assigned(FNetwork) then
- Network.Report(sl);
- if Assigned(FDevices) then
- Devices.Report(sl);
- if Assigned(FEngines) then
- Engines.Report(sl);
- if Assigned(FDirectX) then
- DirectX.Report(sl);
- if Assigned(FDisk) then
- Disk.Report(sl);
- if Assigned(FProcesses) then
- Processes.Report(sl);
- if Assigned(FPrinters) then
- Printers.Report(sl);
- if Assigned(FSoftware) then
- Software.Report(sl);
- if Assigned(FStartup) then
- Startup.Report(sl);
- end;
-
-
- end.
-
-