Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

7 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. using Alphaleonis.Win32.Network;
  22. using System;
  23. using System.Collections.Generic;
  24. using System.Security;
  25. using System.Security.Permissions;
  26. namespace Alphaleonis.Win32.Filesystem
  27. {
  28. /// <summary>Provides access to information of a device, on a local or remote host.</summary>
  29. [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode = true)]
  30. [SerializableAttribute]
  31. [SecurityCritical]
  32. public sealed class DeviceInfo
  33. {
  34. #region Constructors
  35. /// <summary>Initializes a DeviceInfo class.</summary>
  36. [SecurityCritical]
  37. public DeviceInfo()
  38. {
  39. HostName = Host.GetUncName();
  40. }
  41. /// <summary>Initializes a DeviceInfo class.</summary>
  42. /// <param name="host">The DNS or NetBIOS name of the remote server. <see langword="null"/> refers to the local host.</param>
  43. [SecurityCritical]
  44. public DeviceInfo(string host)
  45. {
  46. HostName = Host.GetUncName(host).Replace(Path.UncPrefix, string.Empty);
  47. }
  48. #endregion // Constructors
  49. #region Methods
  50. /// <summary>Enumerates all available devices on the local host.</summary>
  51. /// <param name="deviceGuid">One of the <see cref="DeviceGuid"/> devices.</param>
  52. /// <returns><see cref="IEnumerable{DeviceInfo}"/> instances of type <see cref="DeviceGuid"/> from the local host.</returns>
  53. [SecurityCritical]
  54. public IEnumerable<DeviceInfo> EnumerateDevices(DeviceGuid deviceGuid)
  55. {
  56. return Device.EnumerateDevicesCore(null, HostName, deviceGuid);
  57. }
  58. #endregion // Methods
  59. #region Properties
  60. /// <summary>Represents the <see cref="Guid"/> value of the base container identifier (ID) .The Windows Plug and Play (PnP) manager assigns this value to the device node (devnode).</summary>
  61. public Guid BaseContainerId { get; internal set; }
  62. /// <summary>Represents the name of the device setup class that a device instance belongs to.</summary>
  63. public string Class { get; internal set; }
  64. /// <summary>Represents the <see cref="Guid"/> of the device setup class that a device instance belongs to.</summary>
  65. public Guid ClassGuid { get; internal set; }
  66. /// <summary>Represents the list of compatible identifiers for a device instance.</summary>
  67. public string CompatibleIds { get; internal set; }
  68. /// <summary>Represents a description of a device instance.</summary>
  69. public string DeviceDescription { get; internal set; }
  70. /// <summary>The device interface path.</summary>
  71. public string DevicePath { get; internal set; }
  72. /// <summary>Represents the registry entry name of the driver key for a device instance.</summary>
  73. public string Driver { get; internal set; }
  74. /// <summary>Represents the name of the enumerator for a device instance.</summary>
  75. public string EnumeratorName { get; internal set; }
  76. /// <summary>Represents the friendly name of a device instance.</summary>
  77. public string FriendlyName { get; internal set; }
  78. /// <summary>Represents the list of hardware identifiers for a device instance.</summary>
  79. public string HardwareId { get; internal set; }
  80. /// <summary>The host name that was passed to the class constructor.</summary>
  81. public string HostName { get; internal set; }
  82. /// <summary>Gets the instance Id of the device.</summary>
  83. public string InstanceId { get; internal set; }
  84. /// <summary>Represents the bus-specific physical location of a device instance.</summary>
  85. public string LocationInformation { get; internal set; }
  86. /// <summary>Represents the location of a device instance in the device tree.</summary>
  87. public string LocationPaths { get; internal set; }
  88. /// <summary>Represents the name of the manufacturer of a device instance.</summary>
  89. public string Manufacturer { get; internal set; }
  90. /// <summary>Encapsulates the physical device location information provided by a device's firmware to Windows.</summary>
  91. public string PhysicalDeviceObjectName { get; internal set; }
  92. /// <summary>Represents the name of the service that is installed for a device instance.</summary>
  93. public string Service { get; internal set; }
  94. #endregion // Properties
  95. }
  96. }