求计算机当前名称/操作系统/当前用户名称/cpu型号及处理速度/主板型号/硬盘型号及大小/显卡型号/音卡型号/网卡型号/键盘型号/鼠标型号/
                       每一个都用标签显示,大家帮帮尽快把源代码贴出来一下,<加注释>哦,小
                             弟这里先行谢过,!!!!!!!!!分不够可以再加的,!!!!!

解决方案 »

  1.   

    去查查api大全,或者看《delphi开发与技巧》,就是调用几个api而已啊,学会自己写,碰到真正的问题再问人
      

  2.   

    以下的代码 摘自乔林的《参透Delphi》,获得系统的各种信息的
    你可以去盒子下载,也可以把这段代码贴到你的工程中看看,然后再去查API
    这已经足够了吧。
    unit OSInfo;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ComCtrls, ExtCtrls, JuWindows;type
      TLVCallbackProc = procedure (ListView: TListView; const Name, Content: string) of object;  TFormOSInfo = class(TForm)
        PageControlInfo: TPageControl;
        ButtonOK: TButton;
        TabSheetComputerNames: TTabSheet;
        TabSheetSystemVersion: TTabSheet;
        TabSheetConfiguration: TTabSheet;
        TabSheetMemory: TTabSheet;
        TabSheetMetrics: TTabSheet;
        ListViewComputerNames: TListView;
        Bevel1: TBevel;
        Label1: TLabel;
        ListViewSystemVersion: TListView;
        ListViewConfiguration: TListView;
        ListViewMemoryStatus: TListView;
        ListViewSystemMetrics: TListView;
        TabSheetHardware: TTabSheet;
        ListViewHardware: TListView;
        procedure PageControlInfoChange(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure ButtonOKClick(Sender: TObject);
      private
        { Private declarations }
        FVersionHasShown: Boolean;
        FNamesHasShown: Boolean;
        FConfigurationHasShown: Boolean;
        FMemoryHasShown: Boolean;
        FMetricsHasShown: Boolean;
        FHardwareHasShown: Boolean;
      protected
        function ComputerNameToStr(NameType: TComputerNameFormat): string;
        function RetrieveComputerName(NameType: TComputerNameFormat): string;
        function RetrieveUserName(): string;
        function RetrieveWindowsDirectory(): string;
        function RetrieveSystemDirectory(): string;
        function RetrieveCurrentDirectory(): string;
        function RetrieveEnvironmentVariables(LVCallback: TLVCallbackProc): Integer;
        procedure AddItemTo(ListView: TListView; const Name, Content: string);
      public
        { Public declarations }
        procedure ShowComputerNames();
        procedure ShowSystemVersion();
        procedure ShowConfiguration();
        procedure ShowMemoryStatus();
        procedure ShowSystemMetrics();
        procedure ShowHardware();
      end;var
      FormOSInfo: TFormOSInfo;implementation{$R *.dfm}uses
      Registry;procedure TFormOSInfo.PageControlInfoChange(Sender: TObject);
    begin
      case Self.PageControlInfo.ActivePageIndex of
        0: ShowSystemVersion();
        1: ShowComputerNames();
        2: ShowHardware();
        3: ShowConfiguration();
        4: ShowMemoryStatus();
        5: ShowSystemMetrics();
      end;
    end;procedure TFormOSInfo.ShowComputerNames;
    var
      Iterator: TComputerNameFormat;
    begin
      if Self.FNamesHasShown then exit;
      for Iterator := cnNetBIOS to cnPhysicalDnsFullyQualified do
      begin
        AddItemTo(Self.ListViewComputerNames, ComputerNameToStr(Iterator), RetrieveComputerName(Iterator));
      end;
      Self.FNamesHasShown := True;
    end;procedure TFormOSInfo.FormCreate(Sender: TObject);
    begin
      Self.PageControlInfo.ActivePageIndex := 0;
      Self.ShowSystemVersion();
    end;procedure TFormOSInfo.ShowSystemVersion;
    var
      VersionInfo: TOSVersionInfoEx;
      PlatformStr: string;
      VerExExists: Boolean;
      ProductType: string;
      Reg: TRegistry;
    begin
      if Self.FVersionHasShown then exit;
      VerExExists := True;
      VersionInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
      if not GetVersionEx(POSVersionInfo(@VersionInfo)^) then
      begin
        VersionInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
        GetVersionEx(POSVersionInfo(@VersionInfo)^);
        VerExExists := False;
      end;
      with VersionInfo do
      begin
        case dwPlatformId of
          VER_PLATFORM_WIN32_NT:
          begin
            if (dwMajorVersion = 5) and (dwMinorVersion = 0) then
              PlatformStr := 'Microsoft Windows 2000'
            else if (dwMajorVersion = 5) and (dwMinorVersion = 1) then
              PlatformStr := 'Microsoft Windows XP'
            else if dwMajorVersion = 4 then
              PlatformStr := 'Microsoft Windows NT 4.0'
            else if (dwMajorVersion = 3) and (dwMinorVersion = 51) then
              PlatformStr := 'Microsoft Windows NT 3.51';
    {
            if VerExExists then
            begin
              if wProductType = VER_NT_WORKSTATION then
              begin
                if wSuiteMask and VER_SUITE_PERSONAL then
                  PlatformStr := PlatformStr + ' Personal Workstation'
                else
                  PlatformStr := PlatformStr + ' Professional Workstation';
              end
              else if wProductType = VER_NT_SERVER then
              begin
                if wSuiteMask and VER_SUITE_DATACENTER then
                  PlatformStr := PlatformStr + ' DataCenter Server'
                else if wSuiteMask and VER_SUITE_ENTERPRISE then
                  PlatformStr := PlatformStr + ' Advanced Server'
                else
                  PlatformStr := PlatformStr + ' Server';
              end;
            end
            else
            begin
    }
              Reg := TRegistry.Create();
              try
                Reg.RootKey := HKEY_LOCAL_MACHINE;
                if Reg.OpenKeyReadOnly('SYSTEM\CurrentControlSet\Control\ProductOptions') then
                begin
                  ProductType := Reg.ReadString('ProductType');
                  if SameText(ProductType, 'WinNT') then
                    PlatformStr := PlatformStr + ' Personal Workstation'
                  else if SameText(ProductType, 'LanManNT') then
                    PlatformStr := PlatformStr + ' Server'
                  else if SameText(ProductType, 'ServerNT') then
                    PlatformStr := PlatformStr + ' Advanced Server';
                  Reg.CloseKey();
                end;
              finally
                FreeAndNil(Reg);
              end;
    {
            end;  // if VerExExists
    }
          end;
      

  3.   

    VER_PLATFORM_WIN32_WINDOWS:
          begin
            if (dwMajorVersion = 4) and (dwMinorVersion = 0) then
            begin
              PlatformStr := 'Microsoft Windows 95';
              if szCSDVersion[1] in ['C', 'B'] then
                PlatformStr := PlatformStr + ' OSR2';
            end
            else if (dwMajorVersion = 4) and (dwMinorVersion = 10) then
            begin
              PlatformStr := 'Microsoft Windows 98';
              if szCSDVersion[1] = 'A' then
                PlatformStr := PlatformStr + ' SE';
            end
            else if (dwMajorVersion = 4) and (dwMinorVersion = 90) then
            begin
              PlatformStr := 'Microsoft Windows Me';
            end;
          end;
        end;  // case
      end;  // with VersionInfo
      AddItemTo(Self.ListViewSystemVersion, 'Platform and Product Type', PlatformStr);
      AddItemTo(Self.ListViewSystemVersion, 'Major and Minor Version', Format('%d.%d', [VersionInfo.dwMajorVersion, VersionInfo.dwMinorVersion]));
      AddItemTo(Self.ListViewSystemVersion, 'Build Number', IntToStr(VersionInfo.dwBuildNumber));
      if VerExExists then
      begin
        AddItemTo(Self.ListViewSystemVersion, 'Service Pack Version', Format('%d.%d', [VersionInfo.wServicePackMajor, VersionInfo.wServicePackMinor]));
      end;
      AddItemTo(Self.ListViewSystemVersion, 'CSD Version', VersionInfo.szCSDVersion);
      Self.FVersionHasShown := True;
    end;procedure TFormOSInfo.AddItemTo(ListView: TListView; const Name, Content: string);
    var
      NewItem: TListItem;
    begin
      if not Assigned(ListView) then exit;
      NewItem := ListView.Items.Add();
      NewItem.Caption := Name;
      if Length(Content) <> 0 then NewItem.SubItems.Add(Content) else NewItem.SubItems.Add('<None>');
    end;function TFormOSInfo.ComputerNameToStr(NameType: TComputerNameFormat): string;
    begin
      case NameType of
        cnNetBIOS: Result := 'NetBIOS';
        cnDnsHostname: Result := 'DNS Hostname';
        cnDnsDomain: Result := 'DNS Domain';
        cnFullyQualified: Result := 'Fully Qualified';
        CnPhysicalNetBIOS: Result := 'Physical NetBIOS';
        cnPhysicalDnsHostname: Result := 'Physical DNS Hostname';
        cnPhysicalDnsDomain: Result := 'Physical DNS Domain';
        cnPhysicalDnsFullyQualified: Result := 'Physical DNS Fully Qualified';
        cnMax: Result := 'Max';  // Unused
      end;
    end;procedure TFormOSInfo.ShowConfiguration;
    var
      NewItem: TListItem;
      EnvironStrCount: Integer;
    begin
      if Self.FConfigurationHasShown then exit;
      AddItemTo(Self.ListViewConfiguration, 'User Name', RetrieveUserName());
      AddItemTo(Self.ListViewConfiguration, 'Windows Directory', RetrieveWindowsDirectory());
      AddItemTo(Self.ListViewConfiguration, 'System Directory', RetrieveSystemDirectory());
      AddItemTo(Self.ListViewConfiguration, 'Current Directory', RetrieveCurrentDirectory());  EnvironStrCount := Self.RetrieveEnvironmentVariables(AddItemTo);
      NewItem := Self.ListViewConfiguration.Items.Insert(Self.ListViewConfiguration.Items.Count - EnvironStrCount);
      NewItem.Caption := 'Environment Variables';
      NewItem.SubItems.Add(IntToStr(EnvironStrCount));  Self.FConfigurationHasShown := True;
    end;function TFormOSInfo.RetrieveUserName(): string;
    var
      Size: Cardinal;
      UserName: array [0..255] of Char;
    begin
      GetUserName(UserName, Size);
      Result := UserName;
    end;function TFormOSInfo.RetrieveSystemDirectory: string;
    var
      Dir: array [0..MAX_PATH] of Char;
    begin
      GetSystemDirectory(Dir, SizeOf(Dir));
      Result := Dir;
    end;function TFormOSInfo.RetrieveWindowsDirectory: string;
    var
      Dir: array [0..MAX_PATH] of Char;
    begin
      GetWindowsDirectory(Dir, SizeOf(Dir));
      Result := Dir;
    end;function TFormOSInfo.RetrieveCurrentDirectory: string;
    var
      Dir: array [0..MAX_PATH] of Char;
    begin
      GetCurrentDirectory(SizeOf(Dir), Dir);
      Result := Dir;
    end;function TFormOSInfo.RetrieveComputerName(NameType: TComputerNameFormat): string;
    var
      Name: array [0..255] of Char;
      Size: Cardinal;
    begin
      GetComputerNameEx(NameType, Name, Size);
      Result := Name;
    end;function TFormOSInfo.RetrieveEnvironmentVariables(LVCallback: TLVCallbackProc): Integer;
    var
      P, EnvironStrs: PChar;
      Name, Content: string;
      Index: Integer;
    begin
      Result := 0;
      EnvironStrs := GetEnvironmentStrings();
      P := EnvironStrs;
      repeat
        Name := P;
        Index := Pos('=', Name);
        if Index > 0 then
        begin
          Content := Copy(Name, Index + 1, Length(Name) - Index);
          Name := Copy(Name, 1, Index - 1);
          if Assigned(LVCallback) then LVCallback(Self.ListViewConfiguration, Name, Content);
          Inc(Result);
        end;
        Inc(P, StrLen(P) + 1);
      until P^ = #0;
      FreeEnvironmentStrings(EnvironStrs);
    end;
      

  4.   

    procedure TFormOSInfo.ShowMemoryStatus;
    var
      MemoryStatus: TMemoryStatus;
    begin
      if Self.FMemoryHasShown then exit;  MemoryStatus.dwLength := SizeOf(TMemoryStatus);
      GlobalMemoryStatus(MemoryStatus);  AddItemTo(Self.ListViewMemoryStatus, 'Memory Used', IntToStr(MemoryStatus.dwMemoryLoad) + '%');
      AddItemTo(Self.ListViewMemoryStatus, 'Total Physical Memory', IntToStr(MemoryStatus.dwTotalPhys div 1024) + ' KB');
      AddItemTo(Self.ListViewMemoryStatus, 'Available Physical Memory', IntToStr(MemoryStatus.dwAvailPhys div 1024) + ' KB');
      AddItemTo(Self.ListViewMemoryStatus, 'Total Virtual Memory', IntToStr(MemoryStatus.dwTotalVirtual div 1024) + ' KB');
      AddItemTo(Self.ListViewMemoryStatus, 'Available Virtual Memory', IntToStr(MemoryStatus.dwAvailVirtual div 1024) + ' KB');
      AddItemTo(Self.ListViewMemoryStatus, 'Total Page File Memory', IntToStr(MemoryStatus.dwTotalPageFile div 1024) + ' KB');
      AddItemTo(Self.ListViewMemoryStatus, 'Available Page File Memory', IntToStr(MemoryStatus.dwAvailPageFile div 1024) + ' KB');  Self.FMemoryHasShown := True;
    end;procedure TFormOSInfo.ShowSystemMetrics;
    var
      RetVal: Integer;
      Name, Content: string;
    begin
      if Self.FMetricsHasShown then exit;
      RetVal := GetSystemMetrics(SM_CLEANBOOT);
      case RetVal of
        0: Content := '0: Normal boot';
        1: Content := '1: Fail-safe boot';
        2: Content := '2: Fail-safe with network boot';
      end;
      AddItemTo(Self.ListViewSystemMetrics, 'Clean Boot', Content);  RetVal := GetSystemMetrics(SM_CMOUSEBUTTONS);
      AddItemTo(Self.ListViewSystemMetrics, 'Mouse Buttons', IntToStr(RetVal));  Content := Format('Width: %d; Height: %d', [GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER)]);
      AddItemTo(Self.ListViewSystemMetrics, 'Border', Content);  Content := Format('Width: %d; Height: %d', [GetSystemMetrics(SM_CXCURSOR), GetSystemMetrics(SM_CYCURSOR)]);
      AddItemTo(Self.ListViewSystemMetrics, 'Cursor', Content);  Content := Format('Width: %d; Height: %d', [GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)]);
      AddItemTo(Self.ListViewSystemMetrics, 'Screen', Content);  Content := Format('Width: %d; Height: %d', [GetSystemMetrics(SM_CXFULLSCREEN), GetSystemMetrics(SM_CYFULLSCREEN)]);
      AddItemTo(Self.ListViewSystemMetrics, 'Full Screen', Content);  Content := Format('Height: %d', [GetSystemMetrics(SM_CYMENU)]);
      AddItemTo(Self.ListViewSystemMetrics, 'Single-line Menu', Content);  Self.FMetricsHasShown := True;
    end;procedure TFormOSInfo.ShowHardware;
    var
      SystemInfo: TSystemInfo;
      RetVal: Integer;
      Content: string;
    begin
      if Self.FHardwareHasShown then exit;  GetSystemInfo(SystemInfo);
    {
      case SystemInfo.wProcessorArchitecture of
        PROCESSOR_ARCHITECTURE_INTEL: Content := 'Intel';
        PROCESSOR_ARCHITECTURE_MIPS: Content := 'MIPS';
        PROCESSOR_ARCHITECTURE_ALPHA: Content := 'Alpha';
        PROCESSOR_ARCHITECTURE_PPC: Content := 'PowerPC';
      end;
    }
      Content := 'Intel';
      AddItemTo(Self.ListViewHardware, 'Processor Architecture', Content);
      AddItemTo(Self.ListViewHardware, 'Number of Processors', IntToStr(SystemInfo.dwNumberOfProcessors));
      AddItemTo(Self.ListViewHardware, 'Page Size', IntToStr(SystemInfo.dwPageSize div 1024) +' KB');
      AddItemTo(Self.ListViewHardware, 'Allocation Granularity', IntToStr(SystemInfo.dwAllocationGranularity div 1024) + ' KB');  Content := IntToHex(Integer(SystemInfo.lpMinimumApplicationAddress), 8);
      AddItemTo(Self.ListViewHardware, 'Minimum Application Address', Content);
      Content := IntToHex(Integer(SystemInfo.lpMaximumApplicationAddress), 8);
      AddItemTo(Self.ListViewHardware, 'Maximum Application Address', Content);  RetVal := GetKeyboardType(0);
      case RetVal of
        1: Content := 'IBM PC/XT or compatible (83-key) keyboard';
        2: Content := 'Olivetti "ICO" (102-key) keyboard';
        3: Content := 'IBM PC/AT (84-key) or similar keyboard';
        4: Content := 'IBM enhanced (101- or 102-key) keyboard';
        5: Content := 'Nokia 1050 and similar keyboards';
        6: Content := 'Nokia 9140 and similar keyboards';
        7: Content := 'Japanese keyboard';
      end;
      AddItemTo(Self.ListViewHardware, 'Keyboard Type', Content);  RetVal := GetKeyboardType(2);
      AddItemTo(Self.ListViewHardware, 'Number of Function Keys', IntToStr(RetVal));  Self.FHardwareHasShown := True;
    end;procedure TFormOSInfo.ButtonOKClick(Sender: TObject);
    begin
      Close();
    end;end.