TestComputerInfoForm.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Microsoft.Win32;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using Y.Utils.DataUtils.Collections;
  11. using Y.Utils.DataUtils.UnitConvertUtils;
  12. using Y.Utils.SoftwareUtils;
  13. using Y.Utils.WindowsUtils.InfoUtils;
  14. namespace Y.Test.Views
  15. {
  16. public partial class TestComputerInfoForm : Form
  17. {
  18. public TestComputerInfoForm()
  19. {
  20. InitializeComponent();
  21. }
  22. private void TestComputerInfoForm_Load(object sender, EventArgs e)
  23. {
  24. var softwareinfos = Utils.SoftwareUtils.SoftwareTool.GetControlList();
  25. if (ListTool.HasElements(softwareinfos))
  26. {
  27. softwareinfos.ForEach(x =>
  28. {
  29. if (x.Name != "")
  30. Print(string.Format("{0} / 【{1}】 / {2} / {3} 【{4}】",
  31. x.Name, x.InstallDate, x.Publisher, x.Version,
  32. ByteConvertTool.Fmt(x.EstimatedSize * 1024)));
  33. });
  34. }
  35. }
  36. private void Print(string s)
  37. {
  38. textBox1.AppendText(s);
  39. textBox1.AppendText(Environment.NewLine);
  40. }
  41. private void GetHardInfo()
  42. {
  43. Print("UserName: " + ComputerInfoTool.UserName());
  44. Print("登录用户名: " + ComputerInfoTool.UserName2());
  45. Print("UserDomainName: " + ComputerInfoTool.UserDomainName());
  46. Print("TickCount: " + ComputerInfoTool.TickCount());
  47. Print("ProcessorCount: " + ComputerInfoTool.ProcessorCount());
  48. Print("OSVersion: " + ComputerInfoTool.OSVersion());
  49. Print("Is64BitOperatingSystem: " + ComputerInfoTool.Is64BitOperatingSystem());
  50. Tuple<string, string> cpuinfo = ComputerInfoTool.CpuInfo();
  51. Print("CPU 序列号 " + cpuinfo.Item1 + " 型号 " + cpuinfo.Item2);
  52. Print("显卡信息: " + string.Join(",", ComputerInfoTool.GraphicsCardInfo()));
  53. Print("声卡信息: " + string.Join(",", ComputerInfoTool.SoundCardModel()));
  54. Print("内存: " + ComputerInfoTool.AvailablePhysicalMemory() + " / " + ComputerInfoTool.TotalPhysicalMemory());
  55. List<Tuple<string, string>> harddiskinfo = ComputerInfoTool.HardDiskInfo();
  56. harddiskinfo.ForEach(x =>
  57. {
  58. Print("硬盘 序列号 " + x.Item1 + " 型号 " + x.Item2);
  59. });
  60. var osinfo = ComputerInfoTool.OsInfo();
  61. Print("操作系统: " + osinfo.Item1 + " " + osinfo.Item2 + " " + osinfo.Item3);
  62. Print("系统类型: " + ComputerInfoTool.SystemType());
  63. Print("计算机名: " + ComputerInfoTool.MachineName());
  64. Print("系统所有用户名: " + string.Join(",", ComputerInfoTool.UserNames()));
  65. var boardinfo = ComputerInfoTool.BoardInfo();
  66. Print("主板 制造商 " + boardinfo.Item1 + " 型号 " + boardinfo.Item2 + " 序列号 " + boardinfo.Item3);
  67. }
  68. }
  69. }