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

📄 viewer.pas

📁 一个很不错的系统信息控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        if LiveData then
          RefreshData
        else
          LoadFromStorage(StorageFileName);
        if LogicalID>0 then
          Continue;
        new(pi);
        pi^:=(i+1)+256*Byte(msicCPU);
        s:=Format('%s %s - %d MHz',[cVendorNames[Vendor].Prefix,CPUName,Frequency]);
        n2:=AddChildObject(n1,s,pi);
          new(pi);
          pi^:=(i+1)+256*Byte(msicCPUCache);
          AddChildObject(n2,rsCache,pi);
          new(pi);
          pi^:=(i+1)+256*Byte(msicCPUFS);
          n3:=AddChildObject(n2,rsFeatures,pi);
            if Features.Standard1.Count>0 then begin
              new(pi);
              pi^:=(i+1)+256*Byte(msicCPUFSStd1);
              AddChildObject(n3,rsStandard+'-1',pi);
            end;
            if Features.Standard2.Count>0 then begin
              new(pi);
              pi^:=(i+1)+256*Byte(msicCPUFSStd2);
              AddChildObject(n3,rsStandard+'-2',pi);
            end;
            if Features.Extended1.Count>0 then begin
              new(pi);
              pi^:=(i+1)+256*Byte(msicCPUFSExt1);
              AddChildObject(n3,rsExtended+'-1',pi);
            end;
            if Features.Extended2.Count>0 then begin
              new(pi);
              pi^:=(i+1)+256*Byte(msicCPUFSExt2);
              AddChildObject(n3,rsExtended+'-2',pi);
            end;
            if Features.PowerManagement.Count>0 then begin
              new(pi);
              pi^:=(i+1)+256*Byte(msicCPUFSAPM);
              AddChildObject(n3,rsAPM,pi);
            end;
      end;
    end;
  end;
end;

procedure Tmdi_msi_Viewer.CreateMemoryTree(ARoot: TTreeNode);
var
  n1: TTreeNode;
  pi: PInteger;
  t,i,c: Integer;
  s: string;
begin
  with Tree, Items do begin
    new(pi);
    pi^:=256*BYTE(msicMemory);
    n1:=AddChildObject(ARoot,rsMemory,pi);
    c:=0;
    t:=(MSIC.Memory.PhysicalTotal div 1024) div 1024;
    with MSIC.Machine.SMBIOS do begin
      if MemoryDeviceCount>0 then begin
        for i:=0 to MemoryDeviceCount-1 do
          if (MemoryDevice[i].Size>0) and (c<t) then begin
            c:=c+MemoryDevice[i].Size;
            new(pi);
            pi^:=(i+1)+256*BYTE(msicSMBIOSMemoryDevice);
            if MemoryDevice[i].Device>smmdUnknown then
              s:=MemoryDeviceTypes[MemoryDevice[i].Device]
            else
              s:=MemoryFormFactors[MemoryDevice[i].FormFactor];
            AddChildObject(n1,Format('Row :%d - %d MB %s',[i,MemoryDevice[i].Size,s]),pi);
          end;
      end else
        for i:=0 to MemoryModuleCount-1 do
          if (MemoryModule[i].Size>0) and (c<t) then begin
            c:=c+MemoryModule[i].Size;
            new(pi);
            pi^:=(i+1)+256*BYTE(msicSMBIOSMemoryModule);
            AddChildObject(n1,Format('Row :%d - %d MB %s',[i,
                                                           MemoryModule[i].Size,
                                                           GetMemoryTypeStr(MemoryModule[i].Types)]),pi);
          end;
    end;
  end;
end;

procedure Tmdi_msi_Viewer.CreateAudioTree(ARoot: TTreeNode);
var
  n1,n2: TTreeNode;
  pi: PInteger;
  i,j: Integer;
begin
  with Tree, Items do begin
    new(pi);
    pi^:=256*BYTE(msicOther);
    n1:=AddChildObject(ARoot,rsAudio,pi);
    with MSIC.Devices do
      for i:=0 to DeviceCount-1 do
        if (Devices[i].DeviceClass=dcMedia) and (Devices[i].SymbolicLink<>'') then begin
          new(pi);
          pi^:=(i+1)+256*BYTE(msicAudio);
          n2:=AddChildObject(n1,Devices[i].Name,pi);
        end;
    if n1.Count=0 then
      with MSIC.Media do
        if (WAVEOut.Count>0) then begin
          new(pi);
          pi^:=256*BYTE(msicAudio);
          n2:=AddChildObject(n1,WaveOut[0],pi);
        end;

    if n1.Count=0 then
      n1.Delete;
  end;
end;

procedure Tmdi_msi_Viewer.CreateStorageTree(ARoot: TTreeNode);
var
  n1,n2,n3: TTreeNode;
  pi: PInteger;
  i,j: Integer;
  d,s: string;
begin
  d:='';
  s:=MSIC.Disk.AvailableDisks;

  with Tree, Items do begin
    new(pi);
    pi^:=256*BYTE(msicOther);
    n1:=AddChildObject(ARoot,Format('%s',[rsStorage]),pi);

    new(pi);
    pi^:=256*BYTE(msicOther);
    n2:=AddChildObject(n1,Format('%s %s',[rsWindows,rsStorage]),pi);
    with MSIC.Devices do begin
      for i:=0 to DeviceCount-1 do
        if (Devices[i].DeviceClass in [dcDiskDrive,dcFloppyDisk,dcCDROM,dcTape]) then begin
          new(pi);
          pi^:=(i+1)+256*BYTE(msicWinStorage);
          AddChildObject(n2,Devices[i].Name,pi);
        end;
    end;
    n2.AlphaSort;

    new(pi);
    pi^:=256*BYTE(msicOther);
    n2:=AddChildObject(n1,Format('%s %s',[rsPhysical,rsDevices]),pi);
    with MSIC.Storage do begin
      for i:=0 to PhysicalCount-1 do
        with Physical[i] do begin
          new(pi);
          pi^:=(i+1)+256*BYTE(msicPhysDrive);
          if Size>0 then
            n3:=AddChildObject(n2,Trim(Format('%s (%d MB)',[Model,Size shr 20])),pi)
          else
            n3:=AddChildObject(n2,Format('%s',[Model]),pi);
          for j:=0 to LogicalCount-1 do
            with Logical[j] do
              if PhysicalIndex=i then begin
                new(pi);
                d:=d+Copy(Drive,1,1);
                pi^:=(j+1)+256*BYTE(msicLogDrive);
                if not(DeviceType in [FILE_DEVICE_CD_ROM,FILE_DEVICE_DVD, FILE_DEVICE_TAPE,FILE_DEVICE_UNKNOWN]) and (Length(Layout)>0) and (LayoutIndex>-1) then
                  AddChildObject(n3,Format('%s: (%s %s - %d MB)',[
                                   Drive,
                                   GetPartitionType(Layout[LayoutIndex].Number,Layout[LayoutIndex].Typ),
                                   GetPartitionSystem(Layout[LayoutIndex].Typ),
                                   Layout[LayoutIndex].Length.QuadPart shr 20]),pi)
                else
                  AddChildObject(n3,Format('%s:',[Drive]),pi);
              end;
        end;
    end;
    new(pi);
    pi^:=256*BYTE(msicOther);
    n3:=AddChildObject(n2,'Network drives',pi);
    with MSIC.Disk do
      for i:=1 to Length(s) do begin
        Drive:=Format('%s:\',[Copy(s,i,1)]);
        if MediaType=dtRemote then begin
           d:=d+Copy(Drive,1,1);
           new(pi);
           pi^:=i+256*BYTE(msicNetDrive);;
           AddChildObject(n3,Format('%s (%s)',[Drive,UNCPath]),pi);
        end;
      end;
    if n3.Count=0 then
      Delete(n3);

    new(pi);
    pi^:=256*BYTE(msicOther);
    n3:=AddChildObject(n2,'Removable drives',pi);
    with MSIC.Disk do
      for i:=1 to Length(s) do begin
        Drive:=Format('%s:\',[Copy(s,i,1)]);
        if (Pos(Copy(s,i,1),d)=0) and (MediaType=dtRemovable) then begin
          d:=d+Copy(Drive,1,1);
          new(pi);
          pi^:=i+256*BYTE(msicRemovableDrive);
          AddChildObject(n3,Format('%s',[Drive]),pi);
        end;
      end;
    if n3.Count=0 then
      Delete(n3);

    new(pi);
    pi^:=256*BYTE(msicOther);
    n3:=AddChildObject(n2,'Other drives',pi);
    with MSIC.Disk do
      for i:=1 to Length(s) do begin
        if Pos(Copy(s,i,1),d)=0 then begin
          Drive:=Format('%s:\',[Copy(s,i,1)]);
          new(pi);
          pi^:=i+256*BYTE(msicOtherDrive);
          AddChildObject(n3,Format('%s',[Drive]),pi);
        end;
      end;
    if n3.Count=0 then
      Delete(n3);

    new(pi);
    pi^:=256*BYTE(msicOther);
    n2:=AddChildObject(n1,Format('%s',[rsASPI]),pi);
    with MSIC.Engines.ASPI32 do
      for i:=0 to Configuration.LUN.Count-1 do begin
        new(pi);
        pi^:=(i+1)+256*BYTE(msicASPI);
        AddChildObject(n2,Format('%s%s',[Configuration.Vendor[i],Configuration.Model[i]]),pi);
      end;
  end;
end;

procedure Tmdi_msi_Viewer.CreateMonitorTree(ARoot: TTreeNode);
var
  n1: TTreeNode;
  pi: PInteger;
  i: Integer;
begin
  with Tree, Items do begin
    new(pi);
    pi^:=256*BYTE(msicOther);
    n1:=AddChildObject(ARoot,rsMonitor,pi);
    with MSIC.Monitor do
      for i:=0 to Count-1 do begin
        new(pi);
        pi^:=(i+1)+256*BYTE(msicMonitor);
        AddChildObject(n1,Monitors[i].DeviceDesription,pi);
      end;
    if n1.Count=0 then
      n1.Delete;
  end;
end;

procedure Tmdi_msi_Viewer.CreateNetworkTree(ARoot: TTreeNode);
var
  n1: TTreeNode;
  pi: PInteger;
  i: Integer;
begin
  with Tree, Items do begin
    new(pi);
    pi^:=256*BYTE(msicNetwork);
    n1:=AddChildObject(ARoot,rsNetwork,pi);
    if MSIC.Network.TCPIP.AdapterCount>0 then
      with MSIC.Network.TCPIP do
        for i:=0 to AdapterCount-1 do begin
          new(pi);
          pi^:=(i+1)+256*BYTE(msicNetwork);
          AddChildObject(n1,Adapter[i].Name,pi);
        end
    else
      with MSIC.Network do begin
        for i:=0 to PhysicalAdapters.Count-1 do begin
          new(pi);
          pi^:=(i+1)+256*BYTE(msicNetwork);
          AddChildObject(n1,PhysicalAdapters[i],pi);
        end;
        for i:=0 to VirtualAdapters.Count-1 do begin
          new(pi);
          pi^:=(PhysicalAdapters.Count+i+1)+256*BYTE(msicNetwork);
          AddChildObject(n1,VirtualAdapters[i],pi);
        end;
      end;
    if n1.Count=0 then
      n1.Delete;
  end;
end;

procedure Tmdi_msi_Viewer.CreatePortsTree(ARoot: TTreeNode);
var
  n1,n2: TTreeNode;
  pi: PInteger;
  i: Integer;
begin
  with Tree, Items do begin
    new(pi);
    pi^:=256*BYTE(msicOther);
    n1:=AddChildObject(ARoot,rsPorts,pi);
    new(pi);
    pi^:=256*BYTE(msicOther);
    n2:=AddChildObject(n1,rsCOM,pi);
    with MSIC.Devices do
      for i:=0 to DeviceCount-1 do
        if (Devices[i].DeviceClass=dcPorts) and (Pos('COM',Devices[i].Name)>0) then begin
          new(pi);
          pi^:=(i+1)+256*BYTE(msicDevice);
          AddChildObject(n2,Devices[i].Name,pi);
        end;
    new(pi);
    pi^:=256*BYTE(msicOther);
    n2:=AddChildObject(n1,rsLPT,pi);
    with MSIC.Devices do
      for i:=0 to DeviceCount-1 do
        if (Devices[i].DeviceClass=dcPorts) and (Pos('LPT',Devices[i].Name)>0) then begin
          new(pi);
          pi^:=(i+1)+256*BYTE(msicDevice);
          AddChildObject(n2,Devices[i].Name,pi);
        end;
  end;
end;

procedure Tmdi_msi_Viewer.CreateVideoTree(ARoot: TTreeNode);
var
  n1: TTreeNode;
  pi: PInteger;
  i: Integer;
begin
  with Tree, Items do begin
    new(pi);
    pi^:=256*BYTE(msicOther);
    n1:=AddChildObject(ARoot,rsVideo,pi);
    with MSIC.Devices do
      for i:=0 to DeviceCount-1 do
        if (Devices[i].DeviceClass=dcDisplay) then begin
          new(pi);
          pi^:=(i+1)+256*BYTE(msicVideo);
          AddChildObject(n1,Devices[i].Name,pi);
        end;
  end;
end;

procedure Tmdi_msi_Viewer.TreeChange(Sender: TObject; Node: TTreeNode);
var
  s: string;
begin
  with List, Items do begin
    BeginUpdate;
    try
      Clear;
    finally
      EndUpdate;
    end;
  end;

  if Assigned(Node) then begin
    s:=GetTreePath(Node);
    if Node.Count>0 then
      sb.SimpleText:=Format('%s: %d node(s)',[s,Node.Count])
    else
      sb.SimpleText:=s;
    sb.Hint:=sb.SimpleText;
    if Assigned(Node.Data) then
      case TCategory(Hi(PInteger(Node.Data)^)) of
        msicMachine: DisplayMachineInfo;
        msicCPU: case Lo(PInteger(Node.Data)^) of
          0: DisplayCPUInfo;
          1..31: DisplayCPUDetail(Lo(PInteger(Node.Data)^)-1);
        end;
        msicCPUCache: DisplayCPUCache(Lo(PInteger(Node.Data)^)-1);
        msicCPUFS: DisplayCPUFS(Lo(PInteger(Node.Data)^)-1);
        msicCPUFSStd1: DisplayCPUFSStd1(Lo(PInteger(Node.Data)^)-1);
        msicCPUFSStd2: DisplayCPUFSStd2(Lo(PInteger(Node.Data)^)-1);
        msicCPUFSExt1: DisplayCPUFSExt1(Lo(PInteger(Node.Data)^)-1);
        msicCPUFSExt2: DisplayCPUFSExt2(Lo(PInteger(Node.Data)^)-1);
        msicCPUFSAPM: DisplayCPUFSAPM(Lo(PInteger(Node.Data)^)-1);
        msicMemory: if Lo(PInteger(Node.Data)^)=0 then
                      DisplayMemoryInfo;
        msicMotherBoard: if Lo(PInteger(Node.Data)^)=0 then
                           DisplayMotherBoardInfo;
        msicDevice: if Lo(PInteger(Node.Data)^)=0 then
                     DisplayDeviceInfo
                   else
                     DisplayDeviceDetail(Lo(PInteger(Node.Data)^)-1);
        msicVideo: if Lo(PInteger(Node.Data)^)>0 then
                     DisplayVideoDetail;
        msicMonitor: if Lo(PInteger(Node.Data)^)>0 then
                       DisplayMonitorDetail(Lo(PInteger(Node.Data)^)-1);
        msicAudio: //if Lo(PInteger(Node.Data)^)>0 then
                    DisplayAudioDetail;
        msicNetwork: if Lo(PInteger(Node.Data)^)>0 then
                       DisplayNetworkDetail(Lo(PInteger(Node.Data)^)-1)
                     else
                       DisplayNetworkInfo;
        msicWinStorage: if Lo(PInteger(Node.Data)^)>0 then
                    DisplayWinStorageDetail(Lo(PInteger(Node.Data)^)-1);
        msicPhysDrive: if Lo(PInteger(Node.Data)^)>0 then
                    DisplayPhysDriveDetail(Lo(PInteger(Node.Data)^)-1);
        msicLogDrive: if Lo(PInteger(Node.Data)^)>0 then
                    DisplayLogDriveDetail(Lo(PInteger(Node.Data)^)-1);
        msicNetDrive,
        msicRemovableDrive,

⌨️ 快捷键说明

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