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

📄 viewer.pas

📁 一个很不错的系统信息控件
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        msicOtherDrive: if Lo(PInteger(Node.Data)^)>0 then
                    DisplayOtherDriveDetail(Lo(PInteger(Node.Data)^));
        msicASPI:if Lo(PInteger(Node.Data)^)>0 then
                    DisplayASPIDetail(Lo(PInteger(Node.Data)^)-1);
        msicUSB: if Lo(PInteger(Node.Data)^)>0 then
                   DisplayUSBDetail(Lo(PInteger(Node.Data)^)-1)
                 else
                   DisplayUSBSummary;
        msicPrinter: if Lo(PInteger(Node.Data)^)>0 then
                    DisplayPrinterDetail(Lo(PInteger(Node.Data)^)-1);
        msicSMBIOS: if Lo(PInteger(Node.Data)^)=0 then
                      DisplaySMBIOSInfo;
        msicSMBIOSProcessor: if Lo(PInteger(Node.Data)^)>0 then
                               DisplaySMBIOSProcessorDetail(Lo(PInteger(Node.Data)^)-1);
        msicSMBIOSMemoryModule: if Lo(PInteger(Node.Data)^)>0 then
                      DisplaySMBIOSMemoryModuleDetail(Lo(PInteger(Node.Data)^)-1);
        msicSMBIOSMemorydevice: if Lo(PInteger(Node.Data)^)>0 then
                      DisplaySMBIOSMemoryDeviceDetail(Lo(PInteger(Node.Data)^)-1);
        msicSMBIOSMemCtrl: if Lo(PInteger(Node.Data)^)=0 then
                             DisplaySMBIOSMemCtrlInfo;
        msicSMBIOSBIOS: if Lo(PInteger(Node.Data)^)=0 then
                          DisplaySMBIOSBIOSInfo;
        msicSMBIOSSystem: if Lo(PInteger(Node.Data)^)=0 then
                            DisplaySMBIOSSystemInfo;
        msicSMBIOSChassis: if Lo(PInteger(Node.Data)^)=0 then
                            DisplaySMBIOSChassisInfo;
        msicSMBIOSMainBoard: if Lo(PInteger(Node.Data)^)=0 then
                               DisplaySMBIOSMainboardInfo;
        msicSMBIOSCache: if Lo(PInteger(Node.Data)^)>0 then
                           DisplaySMBIOSCacheDetail(Lo(PInteger(Node.Data)^)-1);
        msicSMBIOSSystemSlot: if Lo(PInteger(Node.Data)^)>0 then
                                DisplaySMBIOSSystemSlotDetail(Lo(PInteger(Node.Data)^)-1);
        msicSMBIOSPort: if Lo(PInteger(Node.Data)^)>0 then
                          DisplaySMBIOSPortDetail(Lo(PInteger(Node.Data)^)-1);
        msicSMBIOSOnBoardDevice: if Lo(PInteger(Node.Data)^)>0 then
                          DisplaySMBIOSOnBoardDeviceDetail(Lo(PInteger(Node.Data)^)-1);
        msicSMBIOSTemperatureProbe: if Lo(PInteger(Node.Data)^)>0 then
                          DisplaySMBIOSTempProbeDetail(Lo(PInteger(Node.Data)^)-1);
        else
          DisplayNodeInfo;
      end;
  end;
end;

function Tmdi_msi_Viewer.GetTreePath(ANode: TTreeNode): string;
begin
  Result:=ANode.Text;
  ANode:=ANode.Parent;
  while Assigned(ANode) do begin
    Result:=ANode.Text+' -> '+Result;
    ANode:=ANode.Parent;
  end;
end;

procedure Tmdi_msi_Viewer.CreateBusTree(ARoot: TTreeNode);
var
  n1,n2,n3: TTreeNode;
  pi: PInteger;
  i,j,k,lastpci,lastdev: Integer;
  sl: TStringList;
begin
  with Tree, Items do begin
    new(pi);
    pi^:=256*BYTE(msicBus);
    n1:=AddChildObject(ARoot,rsBus,pi);
    n2:=nil;

    sl:=TStringList.Create;
    with MSIC.Devices do
      for i:=0 to DeviceCount-1 do
        if (Pos('PCI\',Devices[i].HardwareID)=1) then begin
          if {$IFDEF SIS}StorageInfo.OSPlatform{$ELSE}Win32Platform{$ENDIF}=VER_PLATFORM_WIN32_NT then begin
            if (sl.IndexOf(IntToStr(Devices[i].PCINumber))=-1) {and (Devices[i].DeviceNumber=0)} then begin
              sl.Add(IntToStr(Devices[i].PCINumber));
              lastpci:=Devices[i].PCINumber;
              new(pi);
              pi^:=256*BYTE(msicDevice);
              n2:=AddChildObject(n1,Format('%s %s#%d',[rsPCI,rsBus,Devices[i].PCINumber]),pi);
              for j:=0 to DeviceCount-1 do
                if (Pos('PCI\',Devices[j].HardwareID)=1) then begin
                  if (Devices[j].PCINumber=lastpci) and (Devices[j].FunctionNumber=0) then begin
                    lastdev:=Devices[j].DeviceNumber;
                    new(pi);
                    pi^:=(j+1)+256*BYTE(msicDevice);
                    n3:=AddChildObject(n2,Devices[j].Name,pi);
                    for k:=0 to DeviceCount-1 do
                      if (Pos('PCI\',Devices[k].HardwareID)=1) then begin
                        if (Devices[k].PCINumber=lastpci) and (Devices[k].DeviceNumber=lastdev) and (Devices[k].FunctionNumber>0) then begin
                          new(pi);
                          pi^:=(k+1)+256*BYTE(msicDevice);
                          AddChildObject(n3,Devices[k].Name,pi);
                       end;
                     end;
                  end;
                end;
            end;
          end else begin
            if n2=nil then begin
              new(pi);
              pi^:=256*BYTE(msicDevice);
              n2:=AddChildObject(n1,Format('%s %s',[rsPCI,rsBus]),pi);
            end;
            new(pi);
            pi^:=(i+1)+256*BYTE(msicDevice);
            AddChildObject(n2,Devices[i].Name,pi);
          end;
        end;
      sl.Free;
    if n1.Count=0 then
      n1.Delete;
  end;
end;

procedure Tmdi_msi_Viewer.cmExit(Sender: TObject);
begin
  Close;
end;

procedure Tmdi_msi_Viewer.DisplayMachineInfo;
var
  s: string;
begin
  with List, Items do begin
    BeginUpdate;
    try
      Clear;
      with MSIC.Machine do begin
        with Add do begin
          Caption:=Format('%s %s',[rsMachine,rsName]);
          if Livedata then
            SubItems.Add(MachineName)
          {$IFDEF SIS}else
            SubItems.Add(StorageInfo.Machine){$ENDIF};
          {if VMWare then
            SubItems[0]:=SubItems[0]+' (running under VMWare)';
          if VPC then
            SubItems[0]:=SubItems[0]+' (running under Virtual PC)';}
          ImageIndex:=-3;
        end;
        with Add do begin
          Caption:=rsUsername;
          if LiveData or (User<>'') then begin
            s:=User;
            if IsAdmin then
              s:=s+rsAsAdmin;
          end {$IFDEF SIS}else
            s:=StorageInfo.Security{$ENDIF};
          SubItems.Add(s);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsLastBoot;
          if LiveData or (LastBoot<>0) then
            SubItems.Add(DateTimeToStr(LastBoot))
          else
            SubItems.Add('');
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsSystemUpTime;
          if LiveData or (SystemUpTime<>0) then
            SubItems.Add(FormatSeconds(SystemUpTime,true,false,False))
          else
            SubItems.Add('');
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:='';
          ImageIndex:=-2;
        end;

        with Add do begin
          Caption:=Format('%s %s',[rsBIOS,rsCopyright]);
          SubItems.Add(BIOS.Copyright);
          ImageIndex:=-3;
        end;
        with Add do begin
          Caption:=Format('%s %s',[rsBIOS,rsName]);
          SubItems.Add(BIOS.NameString);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=Format('%s %s',[rsBIOS,rsDate]);
          SubItems.Add(BIOS.Date);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=Format('%s %s',[rsBIOS,rsExtInfo]);
          SubItems.Add(BIOS.ExtendedInfo);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:='';
          ImageIndex:=-2;
        end;
      end;

      with MSIC.OS do begin
        with Add do begin
          Caption:=rsOS;
          if LiveData then begin
            SubItems.Add(Format('%s %d.%d.%d',[OSName,
                                               MajorVersion,
                                               Minorversion,
                                               BuildNumber]));
            with Add do begin
              Caption:=rsEdition;
              SubItems.Add(OSEdition);
              ImageIndex:=-1;
            end;
          end else begin
            {$IFDEF SIS}
            SubItems.Add(Format('%s %d.%d.%d',[StorageInfo.OSName,
                                               StorageInfo.OSMajorVersion,
                                               StorageInfo.OSMinorversion,
                                               StorageInfo.OSBuildNumber]));
            with Add do begin
              Caption:=rsEdition;
              SubItems.Add(StorageInfo.OSEdition);
              ImageIndex:=-1;
            end;
            {$ENDIF}
          end;
          ImageIndex:=-3;
        end;
        if {$IFDEF SIS}StorageInfo.OSPlatform{$ELSE}Win32Platform{$ENDIF}=VER_PLATFORM_WIN32_NT then begin
          with Add do begin
            Caption:=rsSP;
            if LiveData or (CSD<>'') then
              SubItems.Add(CSD)
            {$IFDEF SIS}else
              SubItems.Add(StorageInfo.OSCSDVersion){$ENDIF};
            ImageIndex:=-1;
          end;
        end;
        with Add do begin
          Caption:=rsProductID;
          SubItems.Add(ProductID);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsProductKey;
          SubItems.Add(ProductKey);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsInstallDate;
          if Livedata or (InstallDate<>0) then
            SubItems.Add(DateTimeToStr(InstallDate))
          else
            SubItems.Add('');
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsRegUser;
          SubItems.Add(RegisteredUser);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsRegOrg;
          SubItems.Add(RegisteredOrg);
          ImageIndex:=-1;
        end;
      end;
    finally
      EndUpdate;
    end;
  end;
end;

procedure Tmdi_msi_Viewer.ListAdvancedCustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
  var DefaultDraw: Boolean);
begin
  DefaultDraw:=True;
  with TListView(Sender) do begin
    Canvas.Font.Style:=[];
    if Item.ImageIndex=-3 then
      Canvas.Font.Style:=[fsBold];
    Canvas.Font.Color:=clBlack;
    if cdsHot in State then begin
      Canvas.Font.Color:=clBlue;
      Canvas.Font.Style:=Canvas.Font.Style+[fsUnderLine];
    end else
      Canvas.Font.Style:=Canvas.Font.Style-[fsUnderLine];
    if Item.ImageIndex=-2 then
      ListView_DrawLine(Sender,Item,State,DefaultDraw,clSilver);
  end;
end;

procedure Tmdi_msi_Viewer.CreatePrintersTree(ARoot: TTreeNode);
var
  n1: TTreeNode;
  pi: PInteger;
  i: Integer;
begin
  with Tree, Items do begin
    new(pi);
    pi^:=256*BYTE(msicOther);
    n1:=AddChildObject(ARoot,rsPrinters,pi);
    with MSIC.Printers do
      for i:=0 to PrinterCount-1 do begin
        new(pi);
        pi^:=(i+1)+256*Byte(msicPrinter);
        AddChildObject(n1,PrinterName[i],pi);
      end;
    if n1.Count=0 then
      n1.Delete;
  end;
end;

procedure Tmdi_msi_Viewer.DisplayCPUInfo;
begin
  with List, Items do begin
    BeginUpdate;
    try
      Clear;
      with MSIC.CPU do begin
        with Add do begin
          Caption:=rsCPUPhysCount;
          SubItems.Add(Format('%d',[CPUPhysicalCount]));
          ImageIndex:=-3;
        end;
        Add.ImageIndex:=-2;
        with Add do begin
          Caption:=rsCN;
          SubItems.Add(Format('%d',[CPUPhysicalCount*CorePerPackage]));
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsTN;
          SubItems.Add(Format('%d',[CPUPhysicalCount*LogicalPerPackage]));
          ImageIndex:=-1;
        end;
      end;
    finally
      EndUpdate;
    end;
  end;
end;

procedure Tmdi_msi_Viewer.DisplayCPUDetail;
begin
  with List, Items do begin
    BeginUpdate;
    try
      Clear;
      with MSIC.CPU do begin
        CPUIndex:=AIndex;
        if LiveData then
          RefreshData
        else
          LoadFromStorage(StorageFileName);
        with Add do begin
          Caption:=Format('%s %s',[rsCPU,rsName]);
          SubItems.Add(CPUName);
          ImageIndex:=-3;
        end;
        with Add do begin
          Caption:=rsArchitecture;
          case Architecture of
            PROCESSOR_ARCHITECTURE_AMD64: SubItems.Add('x64 (AMD or Intel)');
            PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: SubItems.Add('WOW64');
            PROCESSOR_ARCHITECTURE_IA64: SubItems.Add('Intel Itanium Processor Family (IPF)');
            PROCESSOR_ARCHITECTURE_INTEL: SubItems.Add('x86');
            else SubItems.Add(Format('%d',[Architecture]));
          end;
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsCPP;
          SubItems.Add(IntToStr(CorePerPackage));
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsLPC;
          SubItems.Add(IntToStr(LogicalPerCore));
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsVendor;
          SubItems.Add(cVendorNames[Vendor].Name);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsFreq;
          SubItems.Add(Format('%d MHz',[Frequency]));
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=Format('%s %s',[rsGeneric,rsName]);
          SubItems.Add(GenericName);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=Format('%s %s',[rsMarketing,rsName]);
          SubItems.Add(MarketingName);
          ImageIndex:=-1;
        end;
        with Add do begin
          Caption:=rsCodeName;

⌨️ 快捷键说明

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