PatchInfoTool.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //************************************************************************
  2. // author: yuzhengyang
  3. // date: 2018.3.27 - 2018.6.3
  4. // desc: 工具描述
  5. // Copyright (c) yuzhengyang. All rights reserved.
  6. //************************************************************************
  7. using Azylee.Core.DataUtils.CollectionUtils;
  8. using Azylee.Core.DataUtils.StringUtils;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Management;
  13. using System.Text;
  14. namespace Azylee.Core.WindowsUtils.InfoUtils
  15. {
  16. public static class PatchInfoTool
  17. {
  18. public static List<string> Get()
  19. {
  20. List<string> rs = new List<string>();
  21. try
  22. {
  23. var searchQFE = new ManagementObjectSearcher("Select * from Win32_QuickFixEngineering");
  24. foreach (var item in searchQFE.Get())
  25. {
  26. string _HotFixID = item.GetPropertyValue("HotFixID").ToString().Trim();
  27. if (!string.IsNullOrWhiteSpace(_HotFixID) && !rs.Contains(_HotFixID))
  28. {
  29. rs.Add(_HotFixID);
  30. }
  31. }
  32. }
  33. catch { }
  34. return rs;
  35. }
  36. public static bool Exist(string name)
  37. {
  38. List<string> list = Get();
  39. if (StringTool.Ok(name) && ListTool.HasElements(list))
  40. {
  41. if (list.Any(x => x == name.Trim())) return true;
  42. }
  43. return false;
  44. }
  45. }
  46. }