⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 MSIC, source code for delphi
💻 PAS
字号:
unit Main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, MSI_GUI, ExtCtrls, ImgList, ComCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    TitlePanel: TPanel;
    Image3: TImage;
    Image4: TImage;
    Image1: TImage;
    Image2: TImage;
    Panel2: TPanel;
    List: TListView;
    Panel3: TPanel;
    img: TImageList;
    MSystemInfo: TMSystemInfo;
    procedure FormCreate(Sender: TObject);
    procedure cmMoveForm(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure cmMinimize(Sender: TObject);
    procedure cmClose(Sender: TObject);
    procedure Image2Click(Sender: TObject);
    procedure cmMaximize(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses MiTeC_Datetime, MiTeC_Routines, MiTeC_CtrlRtns, MSI_SMBIOS, MSI_Devices, MSI_CPU;

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var
  i,c,n,p: Integer;
  s: string;
  k: TSlotType;
begin
  Form_HideCaption(Self);
  try

  with MSystemInfo do begin
    Refresh;
    TitlePanel.Caption:=About;
    with List.Items.Add do begin
      Caption:='System';
      SubItems.Add(Format('%s %s',[Machine.SMBIOS.SystemManufacturer,
                                       Machine.SMBIOS.SystemModel]));
      ImageIndex:=0;
    end;
    with List.Items.Add do begin
      Caption:='Up Time';
      SubItems.Add(Format('%s',[formatseconds(Machine.SystemUpTime,true,false,False)]));
      ImageIndex:=12;
    end;
    with List.Items.Add do ImageIndex:=-1;
    with List.Items.Add do begin
      Caption:='CPU';
      SubItems.Add(Format('%d x %s %s',[CPU.Count,CPUVendors[CPU.vendorType],CPU.FriendlyName]));
      ImageIndex:=9;
    end;
    with List.Items.Add do begin
      Caption:='Frequency';
      SubItems.Add(Format('%d Mhz',[CPU.Frequency]));
      ImageIndex:=13;
    end;
    if Machine.SMBIOS.ProcessorCount>0 then begin
      with List.Items.Add do begin
        Caption:='Voltage';
        SubItems.Add(Format('%1.1fV',[Machine.SMBIOS.Processor[0].Voltage]));
      ImageIndex:=11;
    end;
      with List.Items.Add do begin
        Caption:='Socket';
        SubItems.Add(Format('%s (%s)',[Machine.SMBIOS.Processor[0].Socket,Upgrades[Machine.SMBIOS.Processor[0].Upgrade]]));
        ImageIndex:=14;
      end;
    end;
    with List.Items.Add do ImageIndex:=-1;
    with List.Items.Add do begin
      Caption:='Mainboard';
      SubItems.Add(Format('%s %s',[Machine.SMBIOS.MainboardManufacturer,Machine.SMBIOS.MainboardModel]));
      ImageIndex:=10;
    end;
    c:=0;
    n:=0;
    p:=0;
    s:='';
    if Machine.SMBIOS.MemoryDeviceCount=0 then begin
        for i:=0 to Machine.SMBIOS.MemoryModuleCount-1 do
          if Machine.SMBIOS.MemoryModule[i].Size>0 then begin
            Inc(c);
            n:=Machine.SMBIOS.MemoryModule[i].Size;
            s:=Machine.SMBIOS.GetMemoryTypeStr(Machine.SMBIOS.MemoryModule[i].Types);
            p:=Machine.SMBIOS.MemoryModule[i].Speed;
          end;
      end else
        for i:=0 to Machine.SMBIOS.MemoryDeviceCount-1 do
          if Machine.SMBIOS.MemoryDevice[i].Size>0 then begin
            Inc(c);
            n:=Machine.SMBIOS.MemoryDevice[i].Size;
            if Machine.SMBIOS.MemoryDevice[i].Device>smmdUnknown then
              s:=MemoryDeviceTypes[Machine.SMBIOS.MemoryDevice[i].Device]
            else
              s:=MemoryFormFactors[Machine.SMBIOS.MemoryDevice[i].FormFactor];
            try
              p:=Round(1000/Machine.SMBIOS.MemoryDevice[i].Speed);
            except
              p:=0;
            end;
          end;
    with List.Items.Add do begin
      Caption:='Memory';
      SubItems.Add(Format('%d x %d %s (%d KB free)',[c,n,s,Memory.PhysicalFree div 1024]));
      ImageIndex:=8;
    end;
    with List.Items.Add do begin
      Caption:='Speed';
      SubItems.Add(Format('%d ns',[p]));
      ImageIndex:=8;
    end;

    for i:=0 to Machine.SMBIOS.PortCount-1 do
      with List.Items.Add do begin
        Caption:=Machine.SMBIOS.Port[i].InternalDesignator;
        SubItems.Add(Format('%s (%s/%s)',[PortTypes[Machine.SMBIOS.Port[i].Typ],
                                      ConnectorTypes[Machine.SMBIOS.Port[i].InternalConnector],
                                      ConnectorTypes[Machine.SMBIOS.Port[i].ExternalConnector]]));
        ImageIndex:=2;
      end;
    for k:=Low(TSlotType) to High(TSlotType) do begin
      c:=0;
      for i:=0 to Machine.SMBIOS.SystemSlotCount-1 do
        if Machine.SMBIOS.SystemSlot[i].Typ=k then begin
          Inc(c);
          s:=Format('%s',[DataBusTypes[Machine.SMBIOS.SystemSlot[i].DataBus]]);
        end;
      if c>0 then
        with List.Items.Add do begin
          Caption:=Format('%d x %s',[c,SlotTypes[k]]);
          SubItems.Add(Format('%s',[s]));
          ImageIndex:=3;
        end;
    end;
    with List.Items.Add do ImageIndex:=-1;
    with List.Items.Add do begin
      Caption:=Format('%s %s',[OSVersion,OS.CSD]);
      SubItems.Add(Format('%d.%d.%d',[OS.MajorVersion,OS.MinorVersion,OS.BuildNumber]));
      ImageIndex:=15;
    end;
    with List.Items.Add do begin
      Caption:='Logged User';
      SubItems.Add(Machine.User);
      ImageIndex:=16;
    end;
    with List.Items.Add do ImageIndex:=-1;
    with List.Items.Add do begin
      Caption:='Display Adapter';
      SubItems.Add(Display.Adapter);
      ImageIndex:=1;
    end;
    with List.Items.Add do begin
      Caption:='Resolution';
      SubItems.Add(Format('Resolution: %d x %d - %d bit',[Display.HorzRes,
                                                     Display.VertRes,
                                                     Display.ColorDepth]));
      ImageIndex:=12;
    end;
    with List.Items.Add do begin
      Caption:='Monitor';
      SubItems.Add(Format('%s %s',[Monitor.Monitors[0].Name,Monitor.Monitors[0].ProductNumber]));
      ImageIndex:=1;
    end;
    with List.Items.Add do ImageIndex:=-1;
    if Media.Devices.Count>0 then begin
      with List.Items.Add do begin
        Caption:='Sound Adapter';
        if Media.Devices.Count>0 then begin
          if Media.SoundCardIndex>-1 then
            SubItems.Add(Media.Devices[Media.SoundCardIndex])
          else
            SubItems.Add(Media.Devices[0]);
        end;
        ImageIndex:=4;
      end;
      if (Media.GamePortIndex>-1) and (Media.Devices.Count>0) then
        with List.Items.Add do begin
          Caption:='Game Adapter';
          SubItems.Add(Media.Devices[Media.GamePortIndex]);
          ImageIndex:=5;
        end;
    end;
    with List.Items.Add do ImageIndex:=-1;
    if Network.PhysicalAdapters.Count>0 then begin
      with List.Items.Add do begin
        Caption:='Network Adapter';
        SubItems.Add(Network.PhysicalAdapters[0]);
        ImageIndex:=17;
      end;
      with List.Items.Add do begin
        Caption:='Local Host Name';
        SubItems.Add(Machine.Name);
        ImageIndex:=12;
      end;
      if Network.IPAddresses.Count>0 then
      with List.Items.Add do begin
        Caption:='IP Address';
        SubItems.Add(Network.IPAddresses[0]);
        ImageIndex:=12;
      end;
      if Network.MACAddresses.Count>0 then
      with List.Items.Add do begin
        Caption:='MAC Address';
        SubItems.Add(Network.MACAddresses[0]);
        ImageIndex:=12;
      end;
    end;


    with List.Items.Add do ImageIndex:=-1;
    c:=0;
    for i:=0 to Devices.DeviceCount-1 do
      if Devices.Devices[i].DeviceClass=dcFloppyDisk then
        with List.Items.Add do begin
          Caption:=Format('Floppy Disk %d:',[c]);
          if Trim(Devices.Devices[i].FriendlyName)='' then
            SubItems.Add(Devices.Devices[i].Description)
          else
            SubItems.Add(Devices.Devices[i].FriendlyName);
          ImageIndex:=18;
          Inc(c);
        end;
    c:=0;
    for i:=0 to Devices.DeviceCount-1 do
      if Devices.Devices[i].DeviceClass=dcDiskDrive then
        with List.Items.Add do begin
          Caption:=Format('Hard Disk %d:',[c]);
          if Trim(Devices.Devices[i].FriendlyName)='' then
            SubItems.Add(Devices.Devices[i].Description)
          else
            SubItems.Add(Devices.Devices[i].FriendlyName);
          Inc(c);
          ImageIndex:=19;
        end;

    c:=0;
    for i:=0 to Devices.DeviceCount-1 do
      if Devices.Devices[i].DeviceClass=dcCDROM then
        with List.Items.Add do begin
          Caption:=Format('CDROM %d:',[c]);
          if Trim(Devices.Devices[i].FriendlyName)='' then
            SubItems.Add(Devices.Devices[i].Description)
          else
            SubItems.Add(Devices.Devices[i].FriendlyName);
          Inc(c);
          ImageIndex:=20;
        end;

    c:=0;
    for i:=0 to Devices.DeviceCount-1 do
      if Devices.Devices[i].DeviceClass=dcTapeDrive then
        with List.Items.Add do begin
          Caption:=Format('Tape Drive %d:',[c]);
          if Trim(Devices.Devices[i].FriendlyName)='' then
            SubItems.Add(Devices.Devices[i].Description)
          else
            SubItems.Add(Devices.Devices[i].FriendlyName);
          Inc(c);
          ImageIndex:=21;
        end;

      with List.Items.Add do ImageIndex:=-1;
      s:='<none>';
      for i:=0 to Devices.DeviceCount-1 do
        if Devices.Devices[i].DeviceClass=dcModem then begin
          if Trim(Devices.Devices[i].FriendlyName)='' then
            s:=Devices.Devices[i].Description
          else
            s:=Devices.Devices[i].FriendlyName;
          Break;
        end;

      with List.Items.Add do begin
        Caption:='Modem';
        SubItems.Add(s);
        ImageIndex:=24;
      end;

      with List.Items.Add do ImageIndex:=-1;
      s:='<none>';
      for i:=0 to Devices.DeviceCount-1 do
        if Devices.Devices[i].DeviceClass=dcMouse then begin
          if Trim(Devices.Devices[i].FriendlyName)='' then
            s:=Devices.Devices[i].Description
          else
            s:=Devices.Devices[i].FriendlyName;
          Break;
        end;
      with List.Items.Add do begin
        Caption:='Mouse';
        SubItems.Add(s);
        ImageIndex:=23;
      end;

      with List.Items.Add do ImageIndex:=-1;
      s:='<none>';
      for i:=0 to Devices.DeviceCount-1 do
        if Devices.Devices[i].DeviceClass=dcKeyboard then begin
          if Trim(Devices.Devices[i].FriendlyName)='' then
            s:=Devices.Devices[i].Description
          else
            s:=Devices.Devices[i].FriendlyName;
          Break;
        end;
      with List.Items.Add do begin
        Caption:='Keyboard';
        SubItems.Add(s);
        ImageIndex:=22;
      end;

    with List.Items.Add do ImageIndex:=-1;
    if Printers.Names.Count>0 then
      with List.Items.Add do begin
        Caption:=Printers.Names[Printers.DefaultIndex];
        SubItems.Add(Printers.Ports[Printers.DefaultIndex]);
        ImageIndex:=7;
      end;
    end;

  except
  end;
end;

procedure TForm1.cmMoveForm(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Form_Move(Self);
end;

procedure TForm1.cmMinimize(Sender: TObject);
begin
  Application.Minimize;
end;

procedure TForm1.cmClose(Sender: TObject);
begin
  Close;
end;

procedure TForm1.Image2Click(Sender: TObject);
begin
  MSystemInfo.ShowModalOverviewWithAbout;
end;

procedure TForm1.cmMaximize(Sender: TObject);
begin
  if WindowState=wsNormal then
    WindowState:=wsMaximized
  else
    WindowState:=wsNormal;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -