using System;
using System.Runtime.InteropServices;
using Vanara.Extensions;
using Vanara.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
/// Items from the SetupAPI.dll
public static partial class SetupAPI
{
/// Suite mask used by .
public const ushort SP_ALTPLATFORM_FLAGS_SUITE_MASK = 0x0002;
/// Flag value for indicating post-XP use.
public const ushort SP_ALTPLATFORM_FLAGS_VERSION_RANGE = 0x0001;
private const int LINE_LEN = 256;
private const int MAX_INF_SECTION_NAME_LENGTH = 255; // For Windows 9x compatibility, INF section names should be constrained to 32 characters.
private const int MAX_INF_STRING_LENGTH = 4096; // Actual maximum size of an INF string (including string substitutions).
private const int MAX_INSTALLWIZARD_DYNAPAGES = 20;
private const int MAX_INSTRUCTION_LEN = 256;
private const int MAX_LABEL_LEN = 30;
private const int MAX_PATH = 260; // Redefined here to avoid linking Kernel32
private const int MAX_SERVICE_NAME_LEN = 256;
private const int MAX_SUBTITLE_LEN = 256;
private const int MAX_TITLE_LEN = 60;
/// Define maximum length of a machine name in the format expected by ConfigMgr32 CM_Connect_Machine (i.e., "\\\\MachineName\0").
private const int SP_MAX_MACHINENAME_LENGTH = MAX_PATH + 3;
///
/// A callback routine that displays a progress bar for the device detection operation. The callback routine is supplied by the
/// device installation component that sends the DIF_DETECT request. The callback has the following prototype:
///
///
/// An opaque "handle" that identifies the detection operation. This value is supplied by the device installation component that
/// sent the DIF_DETECT request.
///
///
/// A value between 0 and 100 that indicates the percent completion. The class installer increments this value at various stages of
/// its detection activities, to notify the user of its progress.
///
///
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DETECTDEVICE_PARAMS")]
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate BOOL PDETECT_PROGRESS_NOTIFY([In] IntPtr ProgressNotifyParam, uint DetectComplete);
/// Values for copy and queue-related APIs.
[PInvokeData("setupapi.h")]
[Flags]
public enum CopyStyle : uint
{
/// Delete the source file upon successful copy. The caller is not notified if the deletion fails.
SP_COPY_DELETESOURCE = 0x0000001,
/// Copy the file only if doing so would overwrite a file at the destination path. The caller is not notified.
SP_COPY_REPLACEONLY = 0x0000002,
///
/// Examine each file being copied to see if its version resources indicate that it is either the same version or not newer than
/// an existing copy on the target.
///
/// The file version information used during version checks is that specified in the dwFileVersionMS and dwFileVersionLS members
/// of a VS_FIXEDFILEINFO structure, as filled in by the version functions. If one of the files does not have version resources,
/// or if they have identical version information, the source file is considered newer.
///
///
/// If the source file is not equal in version or newer, and CopyMsgHandler is specified, the caller is notified and may cancel
/// the copy. If CopyMsgHandler is not specified, the file is not copied.
///
///
SP_COPY_NEWER_OR_SAME = 0x0000004,
///
/// Examine each file being copied to see if its version resources indicate that it is not newer than an existing copy on the
/// target. If the source file is newer but not equal in version to the existing target, the file is copied.
///
SP_COPY_NEWER_ONLY = 0x0010000,
///
/// Check whether the target file exists, and if so, notify the caller who may veto the copy. If CopyMsgHandler is not
/// specified, the file is not overwritten.
///
SP_COPY_NOOVERWRITE = 0x0000008,
///
/// Do not decompress the file. When this flag is set, the target file is not given the uncompressed form of the source name (if
/// appropriate). For example, copying f:\x86\cmd.ex_ to \\install\temp results in a target file of \\install\temp\cmd.ex_. If
/// the SP_COPY_NODECOMP flag was not specified, the file would be decompressed and the target would be called
/// \\install\temp\cmd.exe. The file name part of DestinationName, if specified, is stripped and replaced with the file name of
/// the source file. When SP_COPY_NODECOMP is specified, no language or version information can be checked.
///
SP_COPY_NODECOMP = 0x0000010,
///
/// Examine each file being copied to see if its language differs from the language of any existing file already on the target.
/// If so, and CopyMsgHandler is specified, the caller is notified and may cancel the copy. If CopyMsgHandler is not specified,
/// the file is not copied.
///
SP_COPY_LANGUAGEAWARE = 0x0000020,
/// SourceFile is a full source path. Do not look it up in the SourceDisksNames section of the INF file.
SP_COPY_SOURCE_ABSOLUTE = 0x0000040,
///
/// SourcePathRoot is the full path part of the source file. Ignore the relative source specified in the SourceDisksNames
/// section of the INF file for the source media where the file is located. This flag is ignored if SP_COPY_SOURCE_ABSOLUTE is specified.
///
SP_COPY_SOURCEPATH_ABSOLUTE = 0x0000080,
/// If the target exists, behave as if it is in-use and queue the file for copying on the next system reboot.
SP_COPY_FORCE_IN_USE = 0x0000200,
/// If the file was in-use during the copy operation, alert the user that the system needs to be rebooted.
SP_COPY_IN_USE_NEEDS_REBOOT = 0x0000100,
/// Do not give the user the option to skip a file.
SP_COPY_NOSKIP = 0x0000400,
/// Check whether the target file exists, and if so, the file is not overwritten. The caller is not notified.
SP_COPY_FORCE_NOOVERWRITE = 0x0001000,
///
/// Examine each file being copied to see if its version resources (or time stamps for non-image files) indicate that it is not
/// newer than an existing copy on the target. If the file being copied is not newer, the file is not copied. The caller is not notified.
///
SP_COPY_FORCE_NEWER = 0x0002000,
///
/// If the user tries to skip a file, warn them that skipping a file may affect the installation. (Used for system-critical files.)
///
SP_COPY_WARNIFSKIP = 0x0004000,
/// The current source file is continued in another cabinet file.
SP_FLAG_CABINETCONTINUATION = 0x0000800,
/// Do not offer the user the option to browse.
SP_COPY_NOBROWSE = 0x0008000,
/// was: SP_COPY_SOURCE_SIS_MASTER (deprecated)
SP_COPY_RESERVED = 0x0020000,
///
/// The specified .inf file's corresponding catalog files is copied to %windir%\Inf. If this flag is specified, the destination
/// filename information is entered upon successful return if the specified .inf file already exists in the Inf directory.
///
SP_COPY_OEMINF_CATALOG_ONLY = 0x0040000,
/// File must be present upon reboot (i.e., it's needed by the loader); this flag implies a reboot.
SP_COPY_REPLACE_BOOT_FILE = 0x0080000,
/// never prune this file
SP_COPY_NOPRUNE = 0x0100000,
/// Used when calling SetupCopyOemInf
SP_COPY_OEM_F6_INF = 0x0200000,
/// similar to SP_COPY_NODECOMP
SP_COPY_ALREADYDECOMP = 0x0400000,
/// BuildLab or WinSE signed
SP_COPY_WINDOWS_SIGNED = 0x1000000,
/// Used with the signature flag
SP_COPY_PNPLOCKED = 0x2000000,
/// If file in use, try to rename the target first
SP_COPY_IN_USE_TRY_RENAME = 0x4000000,
/// Referred by CopyFiles of inbox inf
SP_COPY_INBOX_INF = 0x8000000,
/// Copy using hardlink, if possible
SP_COPY_HARDLINK = 0x10000000,
}
///
///
/// In Windows Vista and later versions of Windows, the DEVPROPTYPE data type represents the property-data-type identifier that
/// specifies the data type of a device property value in the unified device property model.
///
///
///
///
/// A property-data-type identifier represents a combination of a base data type and a property-data-type modifier. A
/// property-data-type identifier is property-specific, and generally can represent a single fixed-length base-data-type value, a
/// single variable-length base-data-type value, an array of fixed-length base-data-type values, or a list of variable-length
/// base-data-type values.
///
///
/// The device property functions that retrieve or set a device property take a PropertyType parameter that retrieves or supplies
/// the property-data-type identifier for a device property. For example, SetupDiGetDeviceProperty and
/// SetupDiSetDeviceProperty retrieve and set a device property for a device instance.
///
///
// https://docs.microsoft.com/en-us/previous-versions/ff543546(v=vs.85)
[PInvokeData("Devpropdef.h")]
[Flags]
public enum DEVPROPTYPE : uint
{
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPEMOD_ARRAY identifier represents a property-data-type
/// modifier that can be combined with the base-data-type identifiers to create a property-data-type identifier that
/// represents an array of base-data-type values.
///
///
///
/// The DEVPROP_TYPEMOD_ARRAY identifier can be combined only with the fixed-length base-data-type identifiers (
/// DEVPROPTYPE values) that are associated with data. The DEVPROP_TYPEMOD_ARRAY identifier cannot be combined with
/// DEVPROP_TYPE_EMPTY, DEVPROP_TYPE_NULL, or any of the variable-length base-data-type identifiers.
///
///
/// To create a property-data-type identifier that represents an array of base-data-type values, perform a bitwise OR between
/// DEVPROP_TYPEMOD_ARRAY and the corresponding DEVPROP_TYPE_Xxx identifier. For example, to specify an array of unsigned bytes,
/// perform the following bitwise OR: (DEVPROP_TYPEMOD_ARRAY | DEVPROP_TYPE_BYTE).
///
/// The size, in bytes, of an array of base-data-type values is the size, in bytes, of the array.
///
/// For information about how to create a property-data-type identifier that represents a REG_MULTI_SZ list of NULL-terminated
/// Unicode strings, see DEVPROP_TYPEMOD_LIST.
///
///
DEVPROP_TYPEMOD_ARRAY = 0x00001000,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPEMOD_LIST identifier represents a property-data-type modifier
/// that can be combined only with the base-data-type identifiersDEVPROP_TYPE_STRING and
/// DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING to create a property-data-type identifier that represents a REG_MULTI_SZ list
/// of NULL-terminated Unicode strings.
///
///
///
/// DEVPROP_TYPEMOD_LIST cannot be combined with DEVPROP_TYPE_EMPTY, DEVPROP_TYPE_NULL,
/// DEVPROP_TYPE_SECURITY_DESCRIPTOR, or any of the fixed length base-data-type identifiers.
///
///
/// To create a property-data-type identifier that represents a string list, perform a bitwise OR between the
/// DEVPROP_TYPEMOD_LIST property-data-type modifier and the corresponding DEVPROP_TYPE_Xxx identifier. For example, to specify
/// a REG_MULTI_SZ list of Unicode strings, perform the following bitwise OR: (DEVPROP_TYPEMOD_LIST | DEVPROP_TYPE_STRING).
///
///
/// The size of a REG_MULTI_SZ list of NULL-terminated Unicode strings is size of the list including the final NULL that
/// terminated the list.
///
///
/// For information about how to create a property-data-type identifier that represents an array of fixed length data values,
/// see DEVPROP_TYPEMOD_ARRAY.
///
///
DEVPROP_TYPEMOD_LIST = 0x00002000,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_EMPTY identifier represents a special base-data-type
/// identifier that indicates that a property does not exist.
///
///
/// Use this base-data-type identifier with the device property functions to delete a property.
/// If a device property function returns this base-data-type identifier, the property does not exist.
///
/// DEVPROP_TYPE_EMPTY cannot be combined with the property-data-type modifiers DEVPROP_TYPEMOD_ARRAY or DEVPROP_TYPEMOD_LIST.
///
/// Deleting a Property
/// To delete a property, call the corresponding SetupDiSetXxx property function and set the function parameters as follows:
///
/// If DEVPROP_TYPE_EMPTY is used in an attempt to delete a property that does not exist, the delete operation will fail, and a
/// call to GetLastError will return ERROR_NOT_FOUND.
///
/// Retrieving a Property that Does Not Exist
///
/// A call to a SetupDiGetXxx property function that attempts to retrieve a device property that does not exist will fail, and a
/// subsequent call to GetLastError will return ERROR_NOT_FOUND. The called SetupAPI property function will set the
/// *PropertyType parameter to DEVPROP_TYPE_EMPTY.
///
///
DEVPROP_TYPE_EMPTY = 0x00000000,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_NULL identifier represents a special base-data-type
/// identifier that indicates that a device property exists. However, that the property has no value that is associated with the property.
///
///
///
/// Use this base-property-type identifier with the device property functions to delete the value that is associated with a
/// device property.
///
///
/// If a device property function returns this base data type, the property exists, but the property has no value that is
/// associated with it.
///
///
/// The DEVPROP_TYPE_NULL identifier cannot be combined with the property-data-type modifiers DEVPROP_TYPEMOD_ARRAY or DEVPROP_TYPEMOD_LIST.
///
/// Setting a Property of this Type
///
/// To set a property whose data type is DEVPROP_TYPE_NULL, call the corresponding SetupDiSetXxx property function and
/// set the function parameters as follows:
///
/// Retrieving a Property of this Type
///
/// A call to a SetupDiGetXxx property function that attempts to retrieve a device property that has no value will
/// succeed and set the *PropertyType parameter to DEVPROP_TYPE_NULL.
///
///
DEVPROP_TYPE_NULL = 0x00000001,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_BYTE identifier represents the base-data-type identifier
/// that indicates the data type is a SBYTE-typed signed integer.
///
///
/// DEVPROP_TYPE_SBYTE can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose data type is DEVPROP_TYPE_BYTE, call the corresponding SetupDiSetXxx property function, and
/// set the function parameters as follows:
///
///
[CorrespondingType(typeof(sbyte))]
DEVPROP_TYPE_SBYTE = 0x00000002,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_BYTE identifier represents the base-data-type identifier
/// that indicates the data type is a BYTE-typed unsigned integer.
///
///
/// DEVPROP_TYPE_BYTE can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose data type is DEVPROP_TYPE_BYTE, call the corresponding SetupDiSetXxx property function, setting the
/// function input parameters as follows:
///
///
[CorrespondingType(typeof(byte))]
DEVPROP_TYPE_BYTE = 0x00000003,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_INT16 identifier represents the base-data-type identifier
/// that indicates the data type is a SHORT-typed signed integer.
///
///
/// DEVPROP_TYPE_SHORT can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_INT16, call the corresponding SetupDiSetXxx property function
/// and set the function input parameters as follows:
///
///
[CorrespondingType(typeof(short))]
DEVPROP_TYPE_INT16 = 0x00000004,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_UINT16 identifier represents the base-data-type identifier
/// that indicates that the data type is a USHORT-typed unsigned integer.
///
///
/// DEVPROP_TYPE_UINT16 can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_UINT16, call the corresponding SetupDiSetXxx property function
/// and set the function input parameters as follows:
///
///
[CorrespondingType(typeof(ushort))]
DEVPROP_TYPE_UINT16 = 0x00000005,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_INT32 identifier represents the base-data-type identifier
/// that indicates that the data type is a LONG-typed signed integer.
///
///
/// DEVPROP_TYPE_INT32 can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_INT32, call the corresponding SetupDiSetXxx property function,
/// setting the function input parameters as follows:
///
///
[CorrespondingType(typeof(int))]
DEVPROP_TYPE_INT32 = 0x00000006,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_UINT32 identifier represents the base-data-type identifier
/// that indicates that the data type is a ULONG-typed unsigned integer.
///
///
/// DEVPROP_TYPE_UINT32 can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_UINT32, call the corresponding SetupDiSetXxx property function
/// and set the function input parameters as follows:
///
///
[CorrespondingType(typeof(uint))]
DEVPROP_TYPE_UINT32 = 0x00000007,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_INT64 identifier represents the base-data-type identifier
/// that indicates that the data type is a LONG64-typed signed integer.
///
///
/// DEVPROP_TYPE_INT64 can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_INT64, call the corresponding SetupDiSetXxx property function
/// and set the function input parameters as follows:
///
///
[CorrespondingType(typeof(long))]
DEVPROP_TYPE_INT64 = 0x00000008,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_INT64 identifier represents the base-data-type identifier
/// that indicates that the data type is a ULONG64-typed unsigned integer.
///
///
/// DEVPROP_TYPE_UINT64 can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_UINT64, call the corresponding SetupDiSetXxx property function
/// and set the function input parameters as follows:
///
///
[CorrespondingType(typeof(ulong))]
DEVPROP_TYPE_UINT64 = 0x00000009,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_INT64 identifier represents the base-data-type identifier
/// that indicates that the data type is a FLOAT-typed IEEE floating-point number.
///
///
/// DEVPROP_TYPE_FLOAT can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_FLOAT, call the corresponding SetupDiSetXxx property function,
/// setting the function input parameters as follows:
///
///
[CorrespondingType(typeof(float))]
DEVPROP_TYPE_FLOAT = 0x0000000A,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_DOUBLE identifier represents the base-data-type identifier
/// that indicates that the data type is a DOUBLE-typed IEEE floating-point number.
///
///
/// DEVPROP_TYPE_DOUBLE can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_DOUBLE, call the corresponding SetupDiSetXxx property function and
/// set the function input parameters as follows:
///
///
[CorrespondingType(typeof(double))]
DEVPROP_TYPE_DOUBLE = 0x0000000B,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_INT64 identifier represents the base-data-type identifier
/// that indicates that the data type is a DECIMAL-typed value.
///
///
/// DEVPROP_TYPE_DECIMAL can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose data type is DEVPROP_TYPE_DECIMAL, call the corresponding SetupDiSetXxx property function and set
/// the function input parameters as follows:
///
///
[CorrespondingType(typeof(DECIMAL))]
DEVPROP_TYPE_DECIMAL = 0x0000000C,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_GUID identifier represents the base-data-type identifier
/// that indicates that the data type is a GUID-typed globally unique identifier (GUID).
///
///
/// DEVPROP_TYPE_GUID can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_GUID, call the corresponding SetupDiSetXxx property function and set
/// the function input parameters as follows:
///
///
[CorrespondingType(typeof(Guid))]
DEVPROP_TYPE_GUID = 0x0000000D,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_CURRENCY identifier represents the base-data-type
/// identifier that indicates that the data type is a CURRENCY-typed value.
///
///
/// DEVPROP_TYPE_CURRENCY can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of This Type
///
/// To set a property whose base data type is DEVPROP_TYPE_CURRENCY, call the corresponding SetupDiSetXxx property function and
/// set the function input parameters as follows:
///
///
[CorrespondingType(typeof(CY))]
DEVPROP_TYPE_CURRENCY = 0x0000000E,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_DATE property type represents the base-data-type identifier
/// that indicates that the data type is a DOUBLE-typed value that specifies the number of days since December 31, 1899. For
/// example, January 1, 1900, is 1.0; January 2, 1900, is 2.0; and so on.
///
///
/// DEVPROP_TYPE_DATE can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_DATE, call the corresponding SetupDiSetXxx property function and set
/// the function input parameters as follows:
///
///
[CorrespondingType(typeof(DATE))]
DEVPROP_TYPE_DATE = 0x0000000F,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_FILETIME property type represents the base-data-type
/// identifier that indicates that the data type is a FILETIME-typed value.
///
///
/// We recommend that all time values be represented in Coordinated Universal Time (UTC) units.
/// DEVPROP_TYPE_FILETIME can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_FILETIME, call the corresponding SetupDiSetXxx property function and
/// set the function input parameters as follows:
///
///
[CorrespondingType(typeof(FILETIME))]
DEVPROP_TYPE_FILETIME = 0x00000010,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_BOOLEAN property type represents the base-data-type
/// identifier that indicates that the data type is a DEVPROP_BOOLEAN-typed Boolean value.
///
///
/// The DEVPROP_BOOLEAN data type and valid Boolean values are defined as follows:
///
/// typedef CHAR DEVPROP_BOOLEAN, *PDEVPROP_BOOLEAN; #define DEVPROP_TRUE ((DEVPROP_BOOLEAN)-1) #define DEVPROP_FALSE ((DEVPROP_BOOLEAN) 0)
///
/// DEVPROP_TYPE_BOOLEAN can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_BOOLEAN, call the corresponding SetupDiSetXxx property function and
/// set the function input parameters as follows:
///
///
[CorrespondingType(typeof(BOOLEAN))]
DEVPROP_TYPE_BOOLEAN = 0x00000011,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_STRING property type represents the base-data-type
/// identifier that indicates that the data type is a NULL-terminated Unicode string.
///
///
/// DEVPROP_TYPE_STRING can be combined only with the DEVPROP_TYPEMOD_LIST property-data-type modifier.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_STRING, call the corresponding SetupDiSetXxx property
/// function, setting the function input parameters as follows:
///
///
[CorrespondingType(typeof(string))]
DEVPROP_TYPE_STRING = 0x00000012,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_STRING_LIST property type represents the base-data-type
/// identifier that indicates that the data type is a REG_MULTI_SZ-typed list of Unicode strings.
///
///
/// DEVPROP_TYPE_STRING_LIST cannot be combined with the property-data-type modifiers.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_STRING_LIST, call the corresponding SetupDiSetXxx property
/// function and set the function input parameters as follows:
///
///
[CorrespondingType(typeof(System.Collections.Generic.IEnumerable))]
DEVPROP_TYPE_STRING_LIST = DEVPROP_TYPE_STRING | DEVPROP_TYPEMOD_LIST,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_SECURITY_DESCRIPTOR identifier represents the
/// base-data-type identifier that indicates the data type is a variable-length, self-relative, SECURITY_DESCRIPTOR-typed,
/// security descriptor.
///
///
/// DEVPROP_TYPE_SECURITY_DESCRIPTOR cannot be combined with the property-data-type modifiers.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_SECURITY_DESCRIPTOR, call the corresponding SetupDiSetXxx
/// property function and set the function input parameters as follows:
///
///
DEVPROP_TYPE_SECURITY_DESCRIPTOR = 0x00000013,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING identifier represents the
/// base-data-type identifier that indicates the data type is a NULL-terminated Unicode string that contains a security
/// descriptor in the Security Descriptor Definition Language (SDDL) format.
///
///
///
/// DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING can be combined only with the DEVPROP_TYPEMOD_LIST property-data-type modifier.
///
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING, call the corresponding
/// SetupDiSetXxx property function and set the function input parameters as follows:
///
///
[CorrespondingType(typeof(string))]
DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING = 0x00000014,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_DEVPROPKEY identifier represents the base-data-type
/// identifier that indicates the data type is a DEVPROPKEY-typed device property key.
///
///
///
/// The DEVPROP_TYPE_DEVPROPKEY property type can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
///
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_DEVPROPKEY, call the corresponding SetupDiSetXxx property function
/// and set the function input parameters as follows:
///
///
[CorrespondingType(typeof(DEVPROPKEY))]
DEVPROP_TYPE_DEVPROPKEY = 0x00000015,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_DEVPROPTYPE identifier represents the base-data-type
/// identifier that indicates the data type is a DEVPROPTYPE-typed value.
///
///
///
/// The DEVPROP_TYPE_DEVPROPTYPE property type can be combined only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
///
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_DEVPROPTYPE, call the corresponding SetupDiSetXxx property function,
/// setting the function input parameters as follows:
///
///
[CorrespondingType(typeof(DEVPROPTYPE))]
DEVPROP_TYPE_DEVPROPTYPE = 0x00000016,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_TYPE_BINARY identifier represents the base-data-type identifier
/// that indicates that the data type is an array of BYTE-typed unsigned values.
///
///
/// The DEVPROP_TYPE_BINARY property type cannot be combined with the property-data-type modifiers.
/// Setting a Property of this Type
///
/// To set a property whose base data type is DEVPROP_TYPE_BINARY, call the corresponding SetupDiSetXxx property function and
/// set the function input parameters as follows:
///
///
[CorrespondingType(typeof(byte[]))]
DEVPROP_TYPE_BINARY = DEVPROP_TYPE_BYTE | DEVPROP_TYPEMOD_ARRAY,
///
/// The DEVPROP_TYPE_ERROR identifier represents the base-data-type identifier for the Microsoft Win32 error code values that
/// are defined in WINERROR.H.
///
///
///
/// In Windows Vista and later versions of Windows, the unified device property model also defines a
/// DEVPROP_TYPE_NTSTATUS base-data-type identifier for NTSTATUS error code values.
///
/// You can combine DEVPROP_TYPE_ERROR only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of This Type
///
/// To set a property whose base data type is DEVPROP_TYPE_ERROR, call the corresponding SetupDiSetXxx property function and set
/// the function input parameters as follows:
///
/// Retrieving the Descriptive Text for a Win32 Error Code Value
///
/// To retrieve the descriptive text that is associated with a Win32 error code, call the FormatMessage function
/// (documented in the Windows SDK) as follows:
///
///
[CorrespondingType(typeof(Win32Error))]
DEVPROP_TYPE_ERROR = 0x00000017,
///
/// The DEVPROP_TYPE_NTSTATUS identifier represents the base-data-type identifier for the NTSTATUS status code values that are
/// defined in Ntstatus.h.
///
///
///
/// In Windows Vista and later versions of Windows, the unified device property model also defines a DEVPROP_TYPE_ERROR
/// base-data-type identifier for Microsoft Win32 error code values.
///
/// You can combine DEVPROP_TYPE_NTSTATUS only with the DEVPROP_TYPEMOD_ARRAY property-data-type modifier.
/// Setting a Property of This Type
///
/// To set a property whose base data type is DEVPROP_TYPE_NTSTATUS, call the corresponding SetupDiSet Xxx property
/// function and set the function input parameters as follows:
///
/// Retrieving the Descriptive Text for a NTSTATUS Error Code Value
///
/// To retrieve the descriptive text that is associated with an NTSTATUS error code value, call the FormatMessage
/// function (documented in the Windows SDK) as follows:
///
///
[CorrespondingType(typeof(NTStatus))]
DEVPROP_TYPE_NTSTATUS = 0x00000018,
///
/// The DEVPROP_TYPE_STRING_INDIRECT identifier represents the base-data-type identifier for a NULL-terminated Unicode string
/// that contains an indirect string reference.
///
///
///
/// An indirect string reference describes a string resource that contains the actual string. The indirect string reference can
/// appear in one of the following formats:
///
///
/// @[path \]FileName ,- ResourceID Windows extracts the string from the module that is specified by the
/// path and FileName entries, and the resource identifier of the string is supplied by the ResourceID entry (excluding the
/// required minus sign). The string resource is loaded from the module resource section that best matches one of the caller's
/// preferred UI languages. The path entry is optional. If you specify the path entry, the module must be located in a directory
/// that is in the system-defined search path.
///
///
/// @ InfName ,% strkey % Windows extracts the string from the INF Strings section of the INF file
/// in the %SystemRoot%\inf directory whose name is supplied by the InfName entry. The strkey token identifier should match the
/// key of a line in the Strings section that best matches one of the caller's preferred UI languages. If no
/// language-specific Strings sections exist, Windows uses the default Strings section.
///
/// You cannot combine DEVPROP_TYPE_STRING_INDIRECT with any of the property-data-type modifiers.
/// Setting a Property of This Type
///
/// To set a property whose base data type is DEVPROP_TYPE_STRING_INDIRECT, call the corresponding SetupDiSet Xxx
/// property function and set the function input parameters as follows:
///
/// Retrieving the Value of This Property Type
///
/// When an application calls a SetupDiGet Xxx property function to retrieve the value of a property of this base data
/// type, Windows tries to locate the actual string that the property references. If Windows can retrieve the actual string, it
/// returns the actual string to the caller and identifies the base data type of the retrieved property as
/// DEVPROP_TYPE_STRING. Otherwise, Windows returns the indirect string reference and identifies the base data type of
/// the retrieved property as DEVPROP_TYPE_STRING_INDIRECT.
///
/// Localizing Static Text
///
/// Starting with Windows Vista you can localize custom and standard string-type PnP static-text properties using resources from
/// a PE image's string or resource tables by setting static-text property types to DEVPROP_TYPE_STRING_INDIRECT. You can also
/// add non-localized replacement-string data that can be formatted into the static text.
///
///
/// Strings located in a PE image's STRINGTABLE resource (as typically performed by LoadString) should use the following format:
///
/// "@"System32\mydll.dll,-21[;Fallback" String]"
/// "@System32\mydll.dll,-21[;Fallback String with %1, %2, … to %n[;(Arg1,Arg2,…,ArgN)]]"
///
/// Strings located in a PE images's message-table resource (as typically performed by RtlFindMessage, more commonly used in
/// drivers) should use the following format:
///
/// "@System32\drivers\mydriver.sys,#21[;Fallback String]"
/// "@System32\drivers\mydriver.sys,#21[;Fallback String with %1, %2, … to %n[;(Arg1,Arg2,…,ArgN)]]"
///
/// A "Fallback String" is optional but useful because it can be returned if the resource can’t be found or loaded. The fallback
/// string is also returned to non-interactive system processes that are not impersonating a user, and as such cannot show
/// localized text to users anyways.
///
///
/// This technique enables you to localize static-text pulled from the string or message table resource that best matches the
/// caller’s locale.
///
///
/// Windows will format the trailing arguments into the string (or the fallback string) when they are retrieved from the
/// respective resource table, much as in the same manner as RtlFormatMessage does.
///
///
/// Custom and standard string-type PnP static-text is localized when you set the property by loading the resource from the
/// component performing the set operation, which typically happens under the system default locale for system-level components.
///
/// Note: PE images can use either resource table type (STRINGTABLE resources, or message-table resources).
///
[CorrespondingType(typeof(string))]
DEVPROP_TYPE_STRING_INDIRECT = 0x00000019,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_MASK_TYPE mask can be combined in a bitwise AND with a
/// property-data-type identifier to extract the base-data-type identifier from a property-data-type identifier.
///
///
/// This mask cannot be used as a base-data-type identifier, a property-data-type modifier, or a property-data-type identifier.
///
/// For information about how to extract the DEVPROP_TYPEMOD_Xxx property-data-type modifier from a property-data-type
/// identifier, see DEVPROP_MASK_TYPEMOD.
///
///
DEVPROP_MASK_TYPE = 0x00000FFF,
///
/// In Windows Vista and later versions of Windows, the DEVPROP_MASK_TYPEMOD mask can be combined in a bitwise AND with a
/// property-data-type identifier to extract the DEVPROP_TYPEMOD_Xxx property-data-type modifier from a
/// property-data-type identifier.
///
///
/// This mask cannot be used as a base-data-type identifier, a property-data-type modifier, or property-data-type identifier.
///
/// For information about how to extract the base-data-type identifier from a property-data-type identifier, see DEVPROP_MASK_TYPE.
///
///
DEVPROP_MASK_TYPEMOD = 0x0000F000,
}
///
/// Flags that control installation and user interface operations. Some flags can be set before sending the device installation
/// request while other flags are set automatically during the processing of some requests.
///
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DEVINSTALL_PARAMS_A")]
[Flags]
public enum DI_FLAGS : uint
{
///
/// Set to allow support for OEM disks. If this flag is set, the operating system presents a "Have Disk" button on the Select
/// Device page. This flag is set, by default, in system-supplied wizards.
///
DI_SHOWOEM = 0x00000001,
/// show compatibility list
DI_SHOWCOMPAT = 0x00000002,
/// show class list
DI_SHOWCLASS = 0x00000004,
/// both class and compat list shown
DI_SHOWALL = 0x00000007,
/// Set to disable creation of a new copy queue. Use the caller-supplied copy queue in SP_DEVINSTALL_PARAMS. FileQueue.
DI_NOVCP = 0x00000008,
///
/// Set if SetupDiBuildDriverInfoList has already built a list of compatible drivers for this device. If this list has already
/// been built, it contains all the driver information and this flag is always set. SetupDiDestroyDriverInfoList clears this
/// flag when it deletes a compatible driver list.
///
/// This flag is only set in device installation parameters that are associated with a particular device information element,
/// not in parameters for a device information set as a whole.
///
/// This flag is read-only. Only the operating system sets this flag.
///
DI_DIDCOMPAT = 0x00000010,
///
/// Set if SetupDiBuildDriverInfoList has already built a list of the drivers for this class of device. If this list has already
/// been built, it contains all the driver information and this flag is always set. SetupDiDestroyDriverInfoList clears this
/// flag when it deletes a list of drivers for a class.
/// This flag is read-only. Only the operating system sets this flag.
///
DI_DIDCLASS = 0x00000020,
/// No UI for resources if possible flags returned by DiInstallDevice to indicate need to reboot/restart
DI_AUTOASSIGNRES = 0x00000040,
/// The same as DI_NEEDREBOOT.
DI_NEEDRESTART = 0x00000080,
///
/// For NT-based operating systems, this flag is set if the device requires that the computer be restarted after device
/// installation or a device state change. A class installer or co-installer can set this flag at any time during device
/// installation, if the installer determines that a restart is necessary.
///
DI_NEEDREBOOT = 0x00000100,
///
/// Set to disable browsing when the user is selecting an OEM disk path. A device installation application sets this flag to
/// constrain a user to only installing from the installation media location.
///
DI_NOBROWSE = 0x00000200,
///
/// Set by SetupDiBuildDriverInfoList if a list of drivers for a device setup class contains drivers that are provided by
/// multiple manufacturers.
/// This flag is read-only. Only the operating system sets this flag.
///
DI_MULTMFGS = 0x00000400,
/// Set if device disabled Flags for Device/Class Properties
DI_DISABLED = 0x00000800,
///
DI_GENERALPAGE_ADDED = 0x00001000,
///
/// Set by a class installer or co-installer if the installer supplies a page that replaces the system-supplied resource
/// properties page. If this flag is set, the operating system does not display the system-supplied resource page.
///
DI_RESOURCEPAGE_ADDED = 0x00002000,
///
/// Set by Device Manager if a device's properties were changed, which requires an update of the installer's user interface.
///
DI_PROPERTIES_CHANGE = 0x00004000,
///
/// Set to indicate that the Select Device page should list drivers in the order in which they appear in the INF file, instead
/// of sorting them alphabetically.
///
DI_INF_IS_SORTED = 0x00008000,
///
/// Set if installers and other device installation components should only search the INF file specified by
/// SP_DEVINSTALL_PARAMS. DriverPath. If this flag is set, DriverPath contains the path of a single INF file
/// instead of a path of a directory.
///
DI_ENUMSINGLEINF = 0x00010000,
///
/// Set if the configuration manager should not be called to remove or reenumerate devices during the execution of certain
/// device installation functions (for example, SetupDiInstallDevice).
///
/// If this flag is set, device installation applications, class installers, and co-installers must not call the following functions:
///
///
/// CM_Reenumerate_DevNode CM_Reenumerate_DevNode_Ex CM_Query_And_Remove_SubTree CM_Query_And_Remove_SubTree_Ex CM_Setup_DevNode
/// CM_Setup_DevNode_Ex CM_Set_HW_Prof_Flags CM_Set_HW_Prof_Flags_Ex CM_Enable_DevNode CM_Enable_DevNode_Ex CM_Disable_DevNode CM_Disable_DevNode_Ex
///
///
DI_DONOTCALLCONFIGMG = 0x00020000,
///
/// Set if the device should be installed in a disabled state by default. To be recognized, this flag must be set before Windows
/// calls the default handler for the DIF_INSTALLDEVICE request.
///
DI_INSTALLDISABLED = 0x00040000,
///
/// Set to force SetupDiBuildDriverInfoList to build a device's list of compatible drivers from its class driver list instead of
/// the INF file.
///
DI_COMPAT_FROM_CLASS = 0x00080000,
///
/// Set to use the Class Install parameters. SetupDiSetClassInstallParams sets this flag when the caller specifies parameters
/// and clears the flag when the caller specifies a NULL parameters pointer.
///
DI_CLASSINSTALLPARAMS = 0x00100000,
///
/// Set if SetupDiCallClassInstaller should not perform any default action if the class installer returns ERR_DI_DO_DEFAULT or
/// there is not a class installer.
///
DI_NODI_DEFAULTACTION = 0x00200000,
///
/// Set if the device installer functions must be silent and use default choices wherever possible. Class installers and
/// co-installers must not display any UI if this flag is set.
///
DI_QUIETINSTALL = 0x00800000,
/// Set if device installation applications and components, such as SetupDiInstallDevice, should skip file copying.
DI_NOFILECOPY = 0x01000000,
/// Force files to be copied from install path
DI_FORCECOPY = 0x02000000,
///
/// Set by a class installer or co-installer if the installer supplies a page that replaces the system-supplied driver
/// properties page. If this flag is set, the operating system does not display the system-supplied driver page.
///
DI_DRIVERPAGE_ADDED = 0x04000000,
///
/// Set if a class installer or co-installer supplied strings that should be used during SetupDiSelectDevice.
/// The following flags are read-only (only set by the OS):
///
DI_USECI_SELECTSTRINGS = 0x08000000,
/// Override INF flags
DI_OVERRIDE_INFFLAGS = 0x10000000,
/// No Enable/Disable in General Props
[Obsolete]
DI_PROPS_NOCHANGEUSAGE = 0x20000000,
/// No small icons in select device dialogs
[Obsolete]
DI_NOSELECTICONS = 0x40000000,
///
/// Set to prevent SetupDiInstallDevice from writing the INF-specified hardware IDs and compatible IDs to the device properties
/// for the device node (devnode). This flag should only be set for root-enumerated devices.
/// This flag overrides the DI_FLAGSEX_ALWAYSWRITEIDS flag.
///
DI_NOWRITE_IDS = 0x80000000,
}
///
/// Additional flags that provide control over installation and user interface operations. Some flags can be set before calling the
/// device installer functions while other flags are set automatically during the processing of some functions.
///
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DEVINSTALL_PARAMS_A")]
[Flags]
public enum DI_FLAGSEX : uint
{
///
/// If set, include drivers that were marked "Exclude From Select."
///
/// For example, if this flag is set, SetupDiSelectDevice displays drivers that have the Exclude From Select state and
/// SetupDiBuildDriverInfoList includes Exclude From Select drivers in the requested driver list.
///
///
/// A driver is "Exclude From Select" if either it is marked ExcludeFromSelect in the INF file or it is a driver for a
/// device whose whole setup class is marked NoInstallClass or NoUseClass in the class installer INF. Drivers for
/// PnP devices are typically "Exclude From Select"; PnP devices should not be manually installed. To build a list of driver
/// files for a PnP device a caller of SetupDiBuildDriverInfoList must set this flag.
///
///
DI_FLAGSEX_ALLOWEXCLUDEDDRVS = 0x00000800,
///
DI_FLAGSEX_ALTPLATFORM_DRVSEARCH = 0x10000000,
///
///
/// If set and the DI_NOWRITE_IDS flag is clear, always write hardware and compatible IDs to the device properties for the
/// devnode. This flag should only be set for root-enumerated devices.
///
///
DI_FLAGSEX_ALWAYSWRITEIDS = 0x00000200,
///
///
/// If set, SetupDiBuildDriverInfoList appends a new driver list to an existing list. This flag is relevant when
/// searching multiple locations.
///
///
DI_FLAGSEX_APPENDDRIVERLIST = 0x00040000,
/// Reserved.
DI_FLAGSEX_BACKUPONREPLACE = 0x00100000,
///
/// Set by the operating system if a class installer failed to load or start. This flag is read-only.
///
DI_FLAGSEX_CI_FAILED = 0x00000004,
/// Reserved.
DI_FLAGSEX_DEVICECHANGE = 0x00000100,
///
/// Windows has built a list of driver nodes that are compatible with the device. This flag is read-only.
///
DI_FLAGSEX_DIDCOMPATINFO = 0x00000020,
///
///
/// Windows has built a list of driver nodes that includes all the drivers that are listed in the INF files of the specified
/// setup class. If the specified setup class is NULL because the HDEVINFO set or device has no associated class, the
/// list includes all driver nodes from all available INF files. This flag is read-only.
///
///
DI_FLAGSEX_DIDINFOLIST = 0x00000010,
///
///
/// If set, build the driver list from INF(s) retrieved from the URL that is specified in SP_DEVINSTALL_PARAMS.
/// DriverPath. If the DriverPath is an empty string, use the Windows Update website.
///
///
/// Currently, the operating system does not support URLs. Use this flag to direct SetupDiBuildDriverInfoList to search
/// the Windows Update website.
///
/// Do not set this flag if DI_QUIETINSTALL is set.
///
DI_FLAGSEX_DRIVERLIST_FROM_URL = 0x00200000,
///
///
/// If set, do not include old Internet drivers when building a driver list. This flag should be set any time that you are
/// building a list of potential drivers for a device. You can clear this flag if you are just getting a list of drivers
/// currently installed for a device.
///
///
DI_FLAGSEX_EXCLUDE_OLD_INET_DRIVERS = 0x00800000,
///
///
/// If set, SetupDiBuildClassInfoList will check for class inclusion filters. This means that a device will not be included in
/// the class list if its class is marked as NoInstallClass.
///
///
DI_FLAGSEX_FILTERCLASSES = 0x00000040,
///
///
/// (Windows XP and later.) If set, SetupDiBuildDriverInfoList includes "similar" drivers when building a class driver list. A
/// "similar" driver is one for which one of the hardware IDs or compatible IDs in the INF file partially (or completely)
/// matches one of the hardware IDs or compatible IDs of the hardware.
///
///
DI_FLAGSEX_FILTERSIMILARDRIVERS = 0x02000000,
/// Class/co-installer wants to get a DIF_FINISH_INSTALL action in client context.
DI_FLAGSEX_FINISHINSTALL_ACTION = 0x00000008,
///
/// If set, installation is occurring during initial system setup. This flag is read-only.
///
DI_FLAGSEX_IN_SYSTEM_SETUP = 0x00010000,
///
///
/// If set, the driver was obtained from the Internet. Windows will not use the device's INF to install future devices because
/// Windows cannot guarantee that it can retrieve the driver files again from the Internet.
///
///
DI_FLAGSEX_INET_DRIVER = 0x00020000,
///
///
/// (Windows XP and later.) If set, SetupDiBuildDriverInfoList includes only the currently installed driver when creating a list
/// of class drivers or device-compatible drivers.
///
///
DI_FLAGSEX_INSTALLEDDRIVER = 0x04000000,
/// Don't remove identical driver nodes from the class list
DI_FLAGSEX_NO_CLASSLIST_NODE_MERGE = 0x08000000,
///
///
/// Do not process the AddReg and DelReg entries for the device's hardware and software (driver) keys. That is,
/// the AddReg and DelReg entries in the INF file DDInstall and DDInstall .HW sections.
///
///
DI_FLAGSEX_NO_DRVREG_MODIFY = 0x00008000,
/// Obsolete.
[Obsolete]
DI_FLAGSEX_NOUIONQUERYREMOVE = 0x00001000,
///
///
/// If set, an installer added their own page for the power properties dialog. The operating system will not display the
/// system-supplied power properties page. This flag is only relevant if the device supports power management.
///
///
DI_FLAGSEX_POWERPAGE_ADDED = 0x01000000,
/// Reserved.
DI_FLAGSEX_PREINSTALLBACKUP = 0x00080000,
///
///
/// If set, the user made changes to one or more device property sheets. The property-page provider typically sets this flag.
///
///
/// When the user closes the device property sheet, Device Manager checks the DI_FLAGSEX_PROPCHANGE_PENDING flag. If it is set,
/// Device Manager clears this flag, sets the DI_PROPERTIES_CHANGE flag, and sends a DIF_PROPERTYCHANGE request to the
/// installers to notify them that something has changed.
///
///
DI_FLAGSEX_PROPCHANGE_PENDING = 0x00000400,
/// Tell SetupDiBuildDriverInfoList to do a recursive search
DI_FLAGSEX_RECURSIVESEARCH = 0x40000000,
/// Reserved.
DI_FLAGSEX_RESERVED1 = 0x00400000,
/// Reserved.
DI_FLAGSEX_RESERVED2 = 0x00000001,
/// Reserved.
DI_FLAGSEX_RESERVED3 = 0x00000002,
/// Reserved.
DI_FLAGSEX_RESERVED4 = 0x00004000,
/// Only restart the device drivers are being installed on as opposed to restarting all devices using those drivers.
DI_FLAGSEX_RESTART_DEVICE_ONLY = 0x20000000,
/// Tell SetupDiBuildDriverInfoList to do a "published INF" search
DI_FLAGSEX_SEARCH_PUBLISHED_INFS = 0x80000000,
///
///
/// Set if the installation failed. If this flag is set, the SetupDiInstallDevice function just sets the FAILEDINSTALL flag in
/// the device's ConfigFlags registry value. If DI_FLAGSEX_SETFAILEDINSTALL is set, co-installers must return NO_ERROR in
/// response to DIF_INSTALLDEVICE, while class installers must return NO_ERROR or ERROR_DI_DO_DEFAULT.
///
///
DI_FLAGSEX_SETFAILEDINSTALL = 0x00000080,
///
///
/// Filter INF files on the device's setup class when building a list of compatible drivers. If a device's setup class is known,
/// setting this flag reduces the time that is required to build a list of compatible drivers when searching INF files that are
/// not precompiled. This flag is ignored if DI_COMPAT_FROM_CLASS is set.
///
///
DI_FLAGSEX_USECLASSFORCOMPAT = 0x00002000,
}
///
///
/// This section describes the device installation requests that device installation applications send to class installers and
/// co-installers. Each request is represented by a device installation function (DIF) code The DIF code constants are defined in
/// the Setupapi.h header file.
///
///
/// Installers that handle these requests include class installers, class co-installers, and device co-installers. Some installers
/// are provided by Microsoft and some are provided by OEMs and third-party vendors.
///
///
/// Device installation applications send DIF codes to installers by calling SetupDiCallClassInstaller, which in turn calls
/// the installer's entry point function. The DIF code is one of the parameters to the installer's entry point function; other
/// parameters provide additional input. For more information about these parameters, see Handling DIF Codes.
///
/// For information about how to write co-installers, see Writing a Co-installer.
///
// https://docs.microsoft.com/en-us/previous-versions/ff541307(v=vs.85)
[PInvokeData("setupapi.h")]
public enum DI_FUNCTION : uint
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
DIF_SELECTDEVICE = 0x00000001,
DIF_INSTALLDEVICE = 0x00000002,
DIF_ASSIGNRESOURCES = 0x00000003,
DIF_PROPERTIES = 0x00000004,
DIF_REMOVE = 0x00000005,
DIF_FIRSTTIMESETUP = 0x00000006,
DIF_FOUNDDEVICE = 0x00000007,
DIF_SELECTCLASSDRIVERS = 0x00000008,
DIF_VALIDATECLASSDRIVERS = 0x00000009,
DIF_INSTALLCLASSDRIVERS = 0x0000000A,
DIF_CALCDISKSPACE = 0x0000000B,
DIF_DESTROYPRIVATEDATA = 0x0000000C,
DIF_VALIDATEDRIVER = 0x0000000D,
DIF_DETECT = 0x0000000F,
DIF_INSTALLWIZARD = 0x00000010,
DIF_DESTROYWIZARDDATA = 0x00000011,
DIF_PROPERTYCHANGE = 0x00000012,
DIF_ENABLECLASS = 0x00000013,
DIF_DETECTVERIFY = 0x00000014,
DIF_INSTALLDEVICEFILES = 0x00000015,
DIF_UNREMOVE = 0x00000016,
DIF_SELECTBESTCOMPATDRV = 0x00000017,
DIF_ALLOW_INSTALL = 0x00000018,
DIF_REGISTERDEVICE = 0x00000019,
DIF_NEWDEVICEWIZARD_PRESELECT = 0x0000001A,
DIF_NEWDEVICEWIZARD_SELECT = 0x0000001B,
DIF_NEWDEVICEWIZARD_PREANALYZE = 0x0000001C,
DIF_NEWDEVICEWIZARD_POSTANALYZE = 0x0000001D,
DIF_NEWDEVICEWIZARD_FINISHINSTALL = 0x0000001E,
DIF_UNUSED1 = 0x0000001F,
DIF_INSTALLINTERFACES = 0x00000020,
DIF_DETECTCANCEL = 0x00000021,
DIF_REGISTER_COINSTALLERS = 0x00000022,
DIF_ADDPROPERTYPAGE_ADVANCED = 0x00000023,
DIF_ADDPROPERTYPAGE_BASIC = 0x00000024,
DIF_RESERVED1 = 0x00000025,
DIF_TROUBLESHOOTER = 0x00000026,
DIF_POWERMESSAGEWAKE = 0x00000027,
DIF_ADDREMOTEPROPERTYPAGE_ADVANCED = 0x00000028,
DIF_UPDATEDRIVER_UI = 0x00000029,
DIF_FINISHINSTALL_ACTION = 0x0000002A,
DIF_RESERVED2 = 0x00000030,
[Obsolete]
DIF_MOVEDEVICE = 0x0000000E,
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
}
/// Flags that indicate the scope of the device removal.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_REMOVEDEVICE_PARAMS")]
public enum DI_REMOVEDEVICE : uint
{
/// Make this change in all hardware profiles. Remove information about the device from the registry.
DI_REMOVEDEVICE_GLOBAL = 0x00000001,
///
/// Make this change to only the hardware profile specified by HwProfile. this flag only applies to root-enumerated
/// devices. When Windows removes the device from the last hardware profile in which it was configured, Windows performs a
/// global removal.
///
DI_REMOVEDEVICE_CONFIGSPECIFIC = 0x00000002,
}
/// A flag that indicates the scope of the unremove operation.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_UNREMOVEDEVICE_PARAMS")]
public enum DI_UNREMOVEDEVICE
{
/// A flag that indicates the scope of the unremove operation.
DI_UNREMOVEDEVICE_CONFIGSPECIFIC = 0x00000002
}
///
/// Flags used to control exclusion of classes from the list. If no flags are specified, all setup classes are included in the list.
///
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiBuildClassInfoList")]
[Flags]
public enum DIBCI : uint
{
/// Exclude a class if it has the NoInstallClass value entry in its registry key.
DIBCI_NOINSTALLCLASS = 0x00000001,
/// Exclude a class if it has the NoDisplayClass value entry in its registry key.
DIBCI_NODISPLAYCLASS = 0x00000002
}
/// A variable that controls how the device information element is created.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDeviceInfoA")]
[Flags]
public enum DICD : uint
{
///
/// If this flag is specified, DeviceName contains only a Root-enumerated device ID and the system uses that ID to generate a
/// full device instance ID for the new device information element.
///
DICD_GENERATE_ID = 0x00000001,
///
/// If this flag is specified, the resulting device information element inherits the class driver list, if any, associated with
/// the device information set. In addition, if there is a selected driver for the device information set, that same driver is
/// selected for the new device information element.
///
DICD_INHERIT_CLASSDRVS = 0x00000002
}
/// Specifies whether the class is a device setup class or a device interface class.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassPropertyW")]
public enum DICLASSPROP
{
/// ClassGuid specifies a device setup class. This flag cannot be used with DICLASSPROP_INTERFACE.
DICLASSPROP_INSTALLER = 0x00000001,
/// ClassGuid specifies a device interface class. This flag cannot be used with DICLASSPROP_INSTALLER.
DICLASSPROP_INTERFACE = 0x00000002,
}
/// State change action.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_PROPCHANGE_PARAMS")]
public enum DICS : uint
{
///
/// The device is being enabled.
/// For this state change, Windows enables the device if the DICS_FLAG_GLOBAL flag is specified.
///
/// If the DICS_FLAG_CONFIGSPECIFIC flag is specified and the current hardware profile is specified then Windows enables
/// the device. If the DICS_FLAG_CONFIGSPECIFIC is specified and not the current hardware profile then Windows sets some
/// flags in the registry and does not change the device's state. Windows will change the device state when the specified
/// profile becomes the current profile.
///
///
DICS_ENABLE = 0x00000001,
///
/// The device is being disabled.
/// For this state change, Windows disables the device if the DICS_FLAG_GLOBAL flag is specified.
///
/// If the DICS_FLAG_CONFIGSPECIFIC flag is specified and the current hardware profile is specified then Windows disables
/// the device. If the DICS_FLAG_CONFIGSPECIFIC is specified and not the current hardware profile then Windows sets some
/// flags in the registry and does not change the device's state.
///
///
DICS_DISABLE = 0x00000002,
///
/// The properties of the device have changed.
///
/// For this state change, Windows ignores the Scope information as long it is a valid value, and stops and restarts the device.
///
///
DICS_PROPCHANGE = 0x00000003,
///
/// The device is being started (if the request is for the currently active hardware profile).
/// DICS_START must be DICS_FLAG_CONFIGSPECIFIC. You cannot perform that change globally.
///
/// Windows only starts the device if the current hardware profile is specified. Otherwise, Windows sets a registry flag and
/// does not change the state of the device.
///
///
DICS_START = 0x00000004,
///
///
/// Windows only stops the device if the current hardware profile is specified. Otherwise, Windows sets a registry flag and does
/// not change the state of the device.
///
///
/// Components should not specify DICS_STOP or DICS_START. Instead, they should use DICS_PROPCHANGE to stop and restart a device
/// to cause changes in the device's configuration to take effect.
///
///
DICS_STOP = 0x00000005,
}
/// Flags that specify the scope of a device property change.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_PROPCHANGE_PARAMS")]
[Flags]
public enum DICS_FLAG : uint
{
/// Make the change in all hardware profiles.
DICS_FLAG_GLOBAL = 0x00000001,
/// Make the change in the specified profile only.
DICS_FLAG_CONFIGSPECIFIC = 0x00000002,
/// The following flag is obsolete:
[Obsolete]
DICS_FLAG_CONFIGGENERAL = 0x00000004,
}
/// A flag value that indicates how the requested information should be returned.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetCustomDevicePropertyA")]
[Flags]
public enum DICUSTOMDEVPROP : uint
{
///
/// If set, the function retrieves both device instance-specific property values and hardware ID-specific property values,
/// concatenated as a REG_MULTI_SZ-typed string. (For more information, see the Remarks section on this reference page.)
///
DICUSTOMDEVPROP_MERGE_MULTISZ = 0x00000001
}
/// A flag that indicates one of the following types of property sheets.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDevPropertySheetsA")]
public enum DIGCDP_FLAG
{
///
/// Basic property sheets. Supported only in Microsoft Windows 95 and Windows 98. Do not use in Windows 2000 and later versions
/// of Windows.
///
DIGCDP_FLAG_BASIC = 0x00000001,
/// Advanced property sheets.
DIGCDP_FLAG_ADVANCED = 0x00000002,
/// Not implemented.
DIGCDP_FLAG_REMOTE_BASIC = 0x00000003,
/// Advanced property sheets on a remote computer.
DIGCDP_FLAG_REMOTE_ADVANCED = 0x00000004,
}
/// Specifies control options that filter the device information elements that are added to the device information set.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassDevsW")]
[Flags]
public enum DIGCF : uint
{
///
/// Return only the device that is associated with the system default device interface, if one is set, for the specified device
/// interface classes.
///
DIGCF_DEFAULT = 0x00000001,
/// Return only devices that are currently present in a system.
DIGCF_PRESENT = 0x00000002,
/// Return a list of installed devices for all device setup classes or all device interface classes.
DIGCF_ALLCLASSES = 0x00000004,
/// Return only devices that are a part of the current hardware profile.
DIGCF_PROFILE = 0x00000008,
///
/// Return devices that support device interfaces for the specified device interface classes. This flag must be set in the Flags
/// parameter if the Enumerator parameter specifies a device instance ID.
///
DIGCF_DEVICEINTERFACE = 0x00000010,
}
/// The type of registry key to be opened.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenClassRegKeyExA")]
public enum DIOCR : uint
{
/// Open a setup class key. If ClassGuid is NULL, open the root key of the class installer branch.
DIOCR_INSTALLER = 0x00000001,
/// Open an interface class key. If ClassGuid is NULL, open the root key of the interface class branch.
DIOCR_INTERFACE = 0x00000002
}
/// Controls how the device information element is opened.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenDeviceInfoA")]
[Flags]
public enum DIOD : uint
{
///
///
/// If this flag is specified, the resulting device information element inherits the class driver list, if any, associated with
/// the device information set. In addition, if there is a selected driver for the device information set, that same driver is
/// selected for the new device information element.
///
///
/// If the device information element was already present, its class driver list, if any, is replaced with the inherited list.
///
///
DIOD_INHERIT_CLASSDRVS = 0x00000002,
///
/// If this flag is specified and the device had been marked for pending removal, the operating system cancels the pending removal.
///
DIOD_CANCEL_REMOVE = 0x00000004
}
/// Flags that determine how the device interface element is to be opened.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiOpenDeviceInterfaceW")]
[Flags]
public enum DIODI : uint
{
///
/// Specifies that the device information element for the underlying device will not be created if that element is not already
/// present in the specified device information set. For more information, see the following Remarks section.
///
DIODI_NO_ADD = 0x00000001,
}
/// The type of registry storage key to create.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiCreateDevRegKeyA")]
[Flags]
public enum DIREG : uint
{
/// Create a hardware key for the device.
DIREG_DEV = 0x00000001,
/// Create a software key for the device.
DIREG_DRV = 0x00000002,
/// Create both a software and hardware key for the device.
DIREG_BOTH = 0x00000004,
}
/// These flags control the drawing operation.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiDrawMiniIcon")]
[Flags]
public enum DMI : uint
{
/// Draw the mini-icon's mask into HDC.
DMI_MASK = 0x00000001,
///
/// Use the system color index specified in the HIWORD of Flags as the background color. If this flag is not set, COLOR_WINDOW
/// is used.
///
DMI_BKCOLOR = 0x00000002,
/// If set, SetupDiDrawMiniIcon uses the supplied rectangle and stretches the icon to fit.
DMI_USERECT = 0x00000004,
}
/// Flags that control functions operating on this driver.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DRVINSTALL_PARAMS")]
[Flags]
public enum DNF : uint
{
///
///
/// If set, this flag prevents the driver node from being enumerated, regardless of the client that is performing the enumeration.
///
///
DNF_ALWAYSEXCLUDEFROMLIST = 0x00080000,
///
/// This driver's INF file is signed by an Authenticode signature. This flag is read-only to installers.
/// For more information, see Using SetupAPI to Verify Driver Authenticode Signatures.
///
DNF_AUTHENTICODE_SIGNED = 0x00020000,
///
/// Do not use this driver. Installers can read and write this flag.
/// If this flag is set, SetupDiSelectBestCompatDrv and SetupDiSelectDevice ignore this driver.
///
/// A class installer or co-installer can set this flag to prevent Windows from listing the driver in the Select Driver dialog
/// box. An installer might set this flag when it handles a DIF_SELECTDEVICE or DIF_SELECTBESTCOMPATDRV request, for example.
///
///
DNF_BAD_DRIVER = 0x00000800,
///
/// This driver is a basic driver. This flag is read-only to installers.
///
DNF_BASIC_DRIVER = 0x00010000,
///
/// This driver is a class driver. This flag is read-only to installers.
///
DNF_CLASS_DRIVER = 0x00000020,
///
/// This driver is a compatible driver. This flag is read-only to installers.
///
DNF_COMPATIBLE_DRIVER = 0x00000040,
///
///
/// There are other providers supplying drivers that have the same description as this driver. This flag is read-only to installers.
///
///
DNF_DUPDESC = 0x00000001,
///
/// There are other providers supplying drivers that have the same version as this driver. This flag is read-only to installers.
///
DNF_DUPDRIVERVER = 0x00008000,
///
///
/// There are other providers supplying drivers that have the same description as this driver. The only difference between this
/// driver and its match is the driver date. This flag is read-only to installers.
///
///
/// If this flag is set, Windows displays the driver date and driver version next to the driver so that the user can distinguish
/// it from its match.
///
///
DNF_DUPPROVIDER = 0x00001000,
///
/// Do not display this driver in any driver-select dialogs.
///
DNF_EXCLUDEFROMLIST = 0x00000004,
///
/// This driver node is derived from an INF file that was included with this version of Windows.
///
DNF_INBOX_DRIVER = 0x00100000,
///
/// This driver came from the Internet or from Windows Update. This flag is read-only to installers.
///
/// If you call SetupCopyOEMInf you must specify the SPOST_URL flag so that when Windows copies this INF into the
/// %SystemRoot%\inf directory Windows will mark it as an Internet INF. If you omit this step then Windows will attempt to use
/// this device to install other devices. The resulting problem is that Windows does not have the source files any longer and
/// will end up prompting the user with an invalid path.
///
///
DNF_INET_DRIVER = 0x00000080,
///
/// This flag is read-only to installers, and is set if any of the following conditions are true:
///
/// -
/// The driver has a WHQL release signature.
///
/// -
/// The driver is an inbox driver.
///
/// -
/// The driver has an Authenticode signature.
///
///
/// For more information, see Driver Signing.
///
DNF_INF_IS_SIGNED = 0x00002000,
///
/// This driver node is currently installed for the device. This flag is read-only to installers.
///
DNF_INSTALLEDDRIVER = 0x00040000,
///
///
/// This driver comes from a legacy INF file. This flag is valid only for the NT-based operating system. This flag is read-only
/// to installers.
///
///
DNF_LEGACYINF = 0x00000010,
///
/// Set if no physical driver is to be installed for this logical driver.
///
DNF_NODRIVER = 0x00000008,
///
/// Reserved.
///
DNF_OEM_F6_INF = 0x00004000,
///
///
/// This driver came from the Internet, but Windows does not currently have access to its source files. This flag is read-only
/// to installers.
///
///
/// The system will not install a driver marked with this flag because Windows does not have the source files and would end up
/// prompting the user with an invalid path. The INF for such a driver can be used for everything except for installing devices.
///
///
DNF_OLD_INET_DRIVER = 0x00000400,
///
/// This driver currently/previously controlled the associated device. This flag is read-only to installers.
///
DNF_OLDDRIVER = 0x00000002,
///
///
/// Set this flag if the driver package is only part of the software solution that is needed to operate the device. In this
/// case, the driver package requires the installation of additional software.
///
/// For more information, see the following Remarks section.
///
DNF_REQUESTADDITIONALSOFTWARE = 0x00200000,
}
/// A value indicating the type of compression used.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetFileCompressionInfoA")]
[Flags]
public enum FILE_COMPRESSION : uint
{
/// The source file is not compressed with a recognized compression algorithm.
FILE_COMPRESSION_NONE = 0,
/// The source file is compressed with LZ compression.
FILE_COMPRESSION_WINLZA = 1,
/// The source file is compressed with MSZIP compression.
FILE_COMPRESSION_MSZIP = 2,
/// The source file is compressed with Windows Cabinet compression.
FILE_COMPRESSION_NTCAB = 3,
}
/// Type of file operation to be added to the list.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupAddSectionToDiskSpaceListA")]
public enum FILEOP
{
/// A file copy operation.
FILEOP_COPY = 0,
/// A file rename operation.
FILEOP_RENAME = 1,
/// A file delete operation.
FILEOP_DELETE = 2,
/// A file backup operation.
FILEOP_BACKUP = 3,
}
/// File operation return code.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDefaultQueueCallbackA")]
public enum FILEOP_RESULT
{
/// Aborts the operation.
FILEOP_ABORT = 0,
/// Performs the file operation.
FILEOP_DOIT = 1,
/// Skips the operation.
FILEOP_SKIP = 2,
/// Retries the operation.
FILEOP_RETRY = FILEOP_DOIT,
/// Gets a new path for the operation.
FILEOP_NEWPATH = 4,
}
/// Flags that control display formatting and behavior of the dialog box.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupBackupErrorA")]
[Flags]
public enum IDF : uint
{
/// Do not display the browse option.
IDF_NOBROWSE = 0x00000001,
/// Do not display the skip file option.
IDF_NOSKIP = 0x00000002,
///
/// Do not display the details option.
/// If this flag is set, the TargetPathFile and Win32ErrorCode parameters can be omitted.
///
IDF_NODETAILS = 0x00000004,
/// Do not check for compressed versions of the source file.
IDF_NOCOMPRESSED = 0x00000008,
/// Check for the file/disk before displaying the prompt dialog box, and, if present, return DPROMPT_SUCCESS immediately.
IDF_CHECKFIRST = 0x00000100,
/// Prevent the dialog box from beeping to get the user's attention when it first appears.
IDF_NOBEEP = 0x00000200,
/// Prevent the dialog box from becoming the foreground window.
IDF_NOFOREGROUND = 0x00000400,
/// Warns the user that skipping a file can affect the installation.
IDF_WARNIFSKIP = 0x00000800,
///
IDF_NOREMOVABLEMEDIAPROMPT = 0x00001000,
///
IDF_USEDISKNAMEASPROMPT = 0x00002000,
/// The operation source is a disk that a hardware manufacturer provides.
IDF_OEMDISK = 0x80000000,
}
/// Style of the INF file.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_INF_INFORMATION")]
public enum INF_STYLE
{
/// Specifies that the style of the INF file is unrecognized or nonexistent.
INF_STYLE_NONE = 0x00000000,
/// A legacy INF file format.
INF_STYLE_OLDNT = 0x00000001,
/// A Windows INF file format.
INF_STYLE_WIN4 = 0x00000002,
}
/// Flags for .
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupConfigureWmiFromInfSectionA")]
[Flags]
public enum SCWMI : uint
{
///
/// If and only if this flag is set does the security information passed to this function override any security information set
/// elsewhere in the INF file. If this flag does not exist and no security information exists in the INF file, the security is set.
///
SCWMI_CLOBBER_SECURITY = 0x00000001
}
/// A value that identifies the property to be retrieved.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetClassRegistryPropertyA")]
public enum SPCRP
{
///
/// (Windows Vista and later) The function returns a REG_MULTI_SZ list of the service names of the upper filter drivers that are
/// installed for the device setup class.
///
[CorrespondingType(typeof(System.Collections.Generic.IEnumerable))]
[CorrespondingType(typeof(string[]))]
SPCRP_UPPERFILTERS = 0x00000011,
///
/// (Windows Vista and later) The function returns a REG_MULTI_SZ list of the service names of the lower filter drivers that are
/// installed for the device setup class.
///
[CorrespondingType(typeof(System.Collections.Generic.IEnumerable))]
[CorrespondingType(typeof(string[]))]
SPCRP_LOWERFILTERS = 0x00000012,
///
/// The function returns the device's security descriptor as a SECURITY_DESCRIPTOR structure in self-relative format (described
/// in the Microsoft Windows SDK documentation).
///
[CorrespondingType(typeof(byte[]))]
SPCRP_SECURITY = 0x00000017,
///
/// The function returns the device's security descriptor as a text string. For information about security descriptor strings,
/// see Security Descriptor Definition Language (Windows). For information about the format of security descriptor strings, see
/// Security Descriptor Definition Language (Windows).
///
[CorrespondingType(typeof(string))]
SPCRP_SECURITY_SDS = 0x00000018,
///
/// The function returns a DWORD value that represents the device type for the class. For more information, see Specifying
/// Device Types.
///
[CorrespondingType(typeof(FILE_DEVICE))]
SPCRP_DEVTYPE = 0x00000019,
///
/// The function returns a DWORD value indicating whether users can obtain exclusive access to devices for this class. The
/// returned value is one if exclusive access is allowed, or zero otherwise.
///
[CorrespondingType(typeof(BOOL))]
SPCRP_EXCLUSIVE = 0x0000001A,
///
/// The function returns flags indicating device characteristics for the class. For a list of characteristics flags, see the
/// DeviceCharacteristics parameter to IoCreateDevice.
///
[CorrespondingType(typeof(uint))]
SPCRP_CHARACTERISTICS = 0x0000001B,
}
/// The type of driver represented by this structure.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DRVINFO_DATA_V2_A")]
public enum SPDIT : uint
{
/// This structure represents no driver.
SPDIT_NODRIVER = 0x00000000,
/// This structure represents a class driver.
SPDIT_CLASSDRIVER = 0x00000001,
/// This structure represents a compatible driver.
SPDIT_COMPATDRIVER = 0x00000002,
}
/// Specifies the property to be retrieved or set.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiGetDeviceRegistryPropertyA")]
public enum SPDRP
{
/// The function retrieves the device's address.
[CorrespondingType(typeof(uint))]
SPDRP_ADDRESS = 0x0000001C,
/// The function retrieves the device's bus number.
[CorrespondingType(typeof(uint))]
SPDRP_BUSNUMBER = 0x00000015,
/// The function retrieves the GUID for the device's bus type.
[CorrespondingType(typeof(Guid))]
SPDRP_BUSTYPEGUID = 0x00000013,
///
/// The function retrieves a bitwise OR of the following CM_DEVCAP_Xxx flags in a DWORD. The device capabilities that are
/// represented by these flags correspond to the device capabilities that are represented by the members of the
/// DEVICE_CAPABILITIES structure. The CM_DEVCAP_Xxx constants are defined in Cfgmgr32.h.
///
///
/// CM_DEVCAP_Xxx flag
/// Corresponding DEVICE_CAPABILITIES structure member
///
/// -
/// CM_DEVCAP_LOCKSUPPORTED
/// LockSupported
///
/// -
/// CM_DEVCAP_EJECTSUPPORTED
/// EjectSupported
///
/// -
/// CM_DEVCAP_REMOVABLE
/// Removable
///
/// -
/// CM_DEVCAP_DOCKDEVICE
/// DockDevice
///
/// -
/// CM_DEVCAP_UNIQUEID
/// UniqueID
///
/// -
/// CM_DEVCAP_SILENTINSTALL
/// SilentInstall
///
/// -
/// CM_DEVCAP_RAWDEVICEOK
/// RawDeviceOK
///
/// -
/// CM_DEVCAP_SURPRISEREMOVALOK
/// SurpriseRemovalOK
///
/// -
/// CM_DEVCAP_HARDWAREDISABLED
/// HardwareDisabled
///
/// -
/// CM_DEVCAP_NONDYNAMIC
/// NonDynamic
///
///
///
[CorrespondingType(typeof(CM_DEVCAP))]
SPDRP_CAPABILITIES = 0x0000000F,
///
/// The function retrieves a bitwise OR of a device's characteristics flags in a DWORD. For a description of these flags, which
/// are defined in Wdm.h and Ntddk.h, see the DeviceCharacteristics parameter of the IoCreateDevice function.
///
[CorrespondingType(typeof(uint))]
SPDRP_CHARACTERISTICS = 0x0000001B,
/// The function retrieves a REG_SZ string that contains the device setup class of a device.
[CorrespondingType(typeof(string))]
SPDRP_CLASS = 0x00000007,
/// The function retrieves a REG_SZ string that contains the GUID that represents the device setup class of a device.
[CorrespondingType(typeof(string))]
SPDRP_CLASSGUID = 0x00000008,
///
/// The function retrieves a REG_MULTI_SZ string that contains the list of compatible IDs for a device. For information about
/// compatible IDs, see Device Identification Strings.
///
[CorrespondingType(typeof(System.Collections.Generic.IEnumerable))]
[CorrespondingType(typeof(string[]))]
SPDRP_COMPATIBLEIDS = 0x00000002,
///
/// The function retrieves a bitwise OR of a device's configuration flags in a DWORD value. The configuration flags are
/// represented by the CONFIGFLAG_Xxx bitmasks that are defined in Regstr.h.
///
[CorrespondingType(typeof(CONFIGFLAG))]
SPDRP_CONFIGFLAGS = 0x0000000A,
///
/// (Windows XP and later) The function retrieves a CM_POWER_DATA structure that contains the device's power management information.
///
[CorrespondingType(typeof(CM_POWER_DATA))]
SPDRP_DEVICE_POWER_DATA = 0x0000001E,
/// The function retrieves a REG_SZ string that contains the description of a device.
[CorrespondingType(typeof(string))]
SPDRP_DEVICEDESC = 0x00000000,
///
/// The function retrieves a DWORD value that represents the device's type. For more information, see Specifying Device Types.
///
[CorrespondingType(typeof(FILE_DEVICE))]
SPDRP_DEVTYPE = 0x00000019,
///
/// The function retrieves a string that identifies the device's software key (sometimes called the driver key). For more
/// information about driver keys, see Registry Trees and Keys for Devices and Drivers.
///
[CorrespondingType(typeof(string))]
SPDRP_DRIVER = 0x00000009,
/// The function retrieves a REG_SZ string that contains the name of the device's enumerator.
[CorrespondingType(typeof(string))]
SPDRP_ENUMERATOR_NAME = 0x00000016,
///
/// The function retrieves a DWORD value that indicates whether a user can obtain exclusive use of the device. The returned
/// value is one if exclusive use is allowed, or zero otherwise. For more information, see IoCreateDevice.
///
[CorrespondingType(typeof(BOOL))]
SPDRP_EXCLUSIVE = 0x0000001A,
/// The function retrieves a REG_SZ string that contains the friendly name of a device.
[CorrespondingType(typeof(string))]
SPDRP_FRIENDLYNAME = 0x0000000C,
///
/// The function retrieves a REG_MULTI_SZ string that contains the list of hardware IDs for a device. For information about
/// hardware IDs, see Device Identification Strings.
///
[CorrespondingType(typeof(System.Collections.Generic.IEnumerable))]
[CorrespondingType(typeof(string[]))]
SPDRP_HARDWAREID = 0x00000001,
///
/// (Windows XP and later) The function retrieves a DWORD value that indicates the installation state of a device. The
/// installation state is represented by one of the CM_INSTALL_STATE_Xxx values that are defined in Cfgmgr32.h. The
/// CM_INSTALL_STATE_Xxx values correspond to the DEVICE_INSTALL_STATE enumeration values.
///
[CorrespondingType(typeof(CM_INSTALL_STATE))]
SPDRP_INSTALL_STATE = 0x00000022,
/// The function retrieves the device's legacy bus type as an INTERFACE_TYPE value (defined in Wdm.h and Ntddk.h).
[CorrespondingType(typeof(INTERFACE_TYPE))]
SPDRP_LEGACYBUSTYPE = 0x00000014,
/// The function retrieves a REG_SZ string that contains the hardware location of a device.
[CorrespondingType(typeof(string))]
SPDRP_LOCATION_INFORMATION = 0x0000000D,
///
/// (Windows Server 2003 and later) The function retrieves a REG_MULTI_SZ string that represents the location of the device in
/// the device tree.
///
[CorrespondingType(typeof(System.Collections.Generic.IEnumerable))]
[CorrespondingType(typeof(string[]))]
SPDRP_LOCATION_PATHS = 0x00000023,
/// The function retrieves a REG_MULTI_SZ string that contains the names of a device's lower-filter drivers.
[CorrespondingType(typeof(System.Collections.Generic.IEnumerable))]
[CorrespondingType(typeof(string[]))]
SPDRP_LOWERFILTERS = 0x00000012,
/// The function retrieves a REG_SZ string that contains the name of the device manufacturer.
[CorrespondingType(typeof(string))]
SPDRP_MFG = 0x0000000B,
///
/// The function retrieves a REG_SZ string that contains the name that is associated with the device's PDO. For more
/// information, see IoCreateDevice.
///
[CorrespondingType(typeof(string))]
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME = 0x0000000E,
///
/// (Windows XP and later) The function retrieves the device's current removal policy as a DWORD that contains one of the
/// CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
///
[CorrespondingType(typeof(CM_REMOVAL_POLICY))]
SPDRP_REMOVAL_POLICY = 0x0000001F,
///
/// (Windows XP and later) The function retrieves the device's hardware-specified default removal policy as a DWORD that
/// contains one of the CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
///
[CorrespondingType(typeof(CM_REMOVAL_POLICY))]
SPDRP_REMOVAL_POLICY_HW_DEFAULT = 0x00000020,
///
/// (Windows XP and later) The function retrieves the device's override removal policy (if it exists) from the registry, as a
/// DWORD that contains one of the CM_REMOVAL_POLICY_Xxx values that are defined in Cfgmgr32.h.
///
[CorrespondingType(typeof(CM_REMOVAL_POLICY))]
SPDRP_REMOVAL_POLICY_OVERRIDE = 0x00000021,
/// The function retrieves a SECURITY_DESCRIPTOR structure for a device.
[CorrespondingType(typeof(byte[]))]
SPDRP_SECURITY = 0x00000017,
///
/// The function retrieves a REG_SZ string that contains the device's security descriptor. For information about security
/// descriptor strings, see Security Descriptor Definition Language (Windows). For information about the format of security
/// descriptor strings, see Security Descriptor Definition Language (Windows).
///
[CorrespondingType(typeof(string))]
SPDRP_SECURITY_SDS = 0x00000018,
/// The function retrieves a REG_SZ string that contains the service name for a device.
[CorrespondingType(typeof(string))]
SPDRP_SERVICE = 0x00000004,
///
/// The function retrieves a DWORD value set to the value of the UINumber member of the device's DEVICE_CAPABILITIES structure.
///
[CorrespondingType(typeof(uint))]
SPDRP_UI_NUMBER = 0x00000010,
/// The function retrieves a format string (REG_SZ) used to display the UINumber value.
[CorrespondingType(typeof(string))]
SPDRP_UI_NUMBER_DESC_FORMAT = 0x0000001D,
/// The function retrieves a REG_MULTI_SZ string that contains the names of a device's upper filter drivers.
[CorrespondingType(typeof(System.Collections.Generic.IEnumerable))]
[CorrespondingType(typeof(string[]))]
SPDRP_UPPERFILTERS = 0x00000011,
/// Base ContainerID (R)
[CorrespondingType(typeof(Guid))]
SPDRP_BASE_CONTAINERID = 0x00000024,
}
/// Flags for .
[Flags]
public enum SPDSL : uint
{
///
/// File operations added to the list will ignore files that already exist on the disk. For example, if the disk contains a
/// 5000-byte file, C:\MyDir\MyFile, and you add a Copy operation to the disk-space list for a new version, C:\MyDir\MyFile,
/// that is 6500 bytes, the space required will be 6500 bytes (instead of 1500 bytes, which is the value returned if you do not
/// set SPDSL_IGNORE_DISK).
///
SPDSL_IGNORE_DISK = 0x00000001,
///
SPDSL_DISALLOW_NEGATIVE_ADJUST = 0x00000002,
}
/// Notification of a queue action.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDefaultQueueCallbackA")]
public enum SPFILENOTIFY : uint
{
/// Started queued file operations.
SPFILENOTIFY_STARTQUEUE = 0x00000001,
/// Finished queued file operations.
SPFILENOTIFY_ENDQUEUE = 0x00000002,
/// Started a copy, rename, or delete subqueue.
SPFILENOTIFY_STARTSUBQUEUE = 0x00000003,
/// Finished a copy, rename, or delete subqueue.
SPFILENOTIFY_ENDSUBQUEUE = 0x00000004,
/// Started a delete operation.
SPFILENOTIFY_STARTDELETE = 0x00000005,
/// Finished a delete operation.
SPFILENOTIFY_ENDDELETE = 0x00000006,
/// Encountered an error while deleting a file.
SPFILENOTIFY_DELETEERROR = 0x00000007,
/// Started a rename operation.
SPFILENOTIFY_STARTRENAME = 0x00000008,
/// Finished a rename operation.
SPFILENOTIFY_ENDRENAME = 0x00000009,
/// Encountered an error while renaming a file.
SPFILENOTIFY_RENAMEERROR = 0x0000000a,
/// Started a copy operation.
SPFILENOTIFY_STARTCOPY = 0x0000000b,
/// Finished a copy operation.
SPFILENOTIFY_ENDCOPY = 0x0000000c,
/// Encountered an error while copying a file.
SPFILENOTIFY_COPYERROR = 0x0000000d,
/// New media is required.
SPFILENOTIFY_NEEDMEDIA = 0x0000000e,
/// A node in the file queue has been scanned.
SPFILENOTIFY_QUEUESCAN = 0x0000000f,
///
SPFILENOTIFY_CABINETINFO = 0x00000010,
/// A file is encountered in the cabinet.
SPFILENOTIFY_FILEINCABINET = 0x00000011,
/// The current file is continued in the next cabinet.
SPFILENOTIFY_NEEDNEWCABINET = 0x00000012,
/// The file has been extracted from the cabinet.
SPFILENOTIFY_FILEEXTRACTED = 0x00000013,
/// The file was in use, and the current operation has been delayed until the system is rebooted.
SPFILENOTIFY_FILEOPDELAYED = 0x00000014,
/// Started a backup operation.
SPFILENOTIFY_STARTBACKUP = 0x00000015,
/// Encountered an error while copying a file.
SPFILENOTIFY_BACKUPERROR = 0x00000016,
/// Finished a backup operation.
SPFILENOTIFY_ENDBACKUP = 0x00000017,
/// A node in the file queue has been scanned.
SPFILENOTIFY_QUEUESCAN_EX = 0x00000018,
/// The registration or unregistration of the file has started.
SPFILENOTIFY_STARTREGISTRATION = 0x00000019,
/// The registration or unregistration of the file has finished.
SPFILENOTIFY_ENDREGISTRATION = 0x00000020,
/// A node in the file queue has been scanned.
SPFILENOTIFY_QUEUESCAN_SIGNERINFO = 0x00000040,
/// Existing target file is in a different language than the source.
SPFILENOTIFY_LANGMISMATCH = 0x00010000,
/// Target file exists.
SPFILENOTIFY_TARGETEXISTS = 0x00020000,
/// Existing target file is newer than source.
SPFILENOTIFY_TARGETNEWER = 0x00040000,
}
/// Flags for .
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DEVICE_INTERFACE_DATA")]
[Flags]
public enum SPINT : uint
{
/// The interface is active (enabled).
SPINT_ACTIVE = 0x00000001,
/// The interface is the default interface for the device class.
SPINT_DEFAULT = 0x00000002,
/// The interface is removed.
SPINT_REMOVED = 0x00000004
}
/// The property sheet page to add to the property sheet.
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_PROPSHEETPAGE_REQUEST")]
public enum SPPSR : uint
{
/// Specifies the Resource Selection page supplied by the SetupAPI DLL.
SPPSR_SELECT_DEVICE_RESOURCES = 1,
///
/// Specifies a page that is supplied by the device's BasicProperties32 provider. That is, an installer or other component that
/// supplied page(s) in response to a DIF_ADDPROPERTYPAGE_BASIC installation request.
///
SPPSR_ENUM_BASIC_DEVICE_PROPERTIES,
///
/// Specifies a page that is supplied by the class and/or the device's EnumPropPages32 provider. That is, an installer or other
/// component that supplied page(s) in response to a DIF_ADDPROPERTYPAGE_ADVANCED installation request.
///
SPPSR_ENUM_ADV_DEVICE_PROPERTIES,
}
/// A flag value that controls how the device is registered.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDiRegisterDeviceInfo")]
[Flags]
public enum SPRDI : uint
{
///
/// Search for a previously-existing device instance that corresponds to the device that is represented by DeviceInfoData. If
/// this flag is not specified, the device instance is registered regardless of whether a device instance already exists for it.
///
SPRDI_FIND_DUPS = 0x00000001
}
///
/// For a SPFILENOTIFY_STARTREGISTRATION notification, this member is not used and should be set to SPREG_SUCCESS. For a
/// SPFILENOTIFY_ENDREGISTRATION notification, set to one of the following failure codes that indicate the result of registration.
///
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_REGISTER_CONTROL_STATUSA")]
public enum SPREG : uint
{
/// The file was successfully registered or unregistered. WinError not used.
SPREG_SUCCESS = 0x00000000,
/// LoadLibrary failed for the file. WinError contains an extended error code from the component.
SPREG_LOADLIBRARY = 0x00000001,
/// GetProcAddress failed for the file. WinError contains an extended error code from the component.
SPREG_GETPROCADDR = 0x00000002,
/// DLLRegisterServer entry point returned failure. WinError contains an extended error code from the component.
SPREG_REGSVR = 0x00000003,
/// DLLInstall entry point returned failure. WinError contains an extended error code from the component.
SPREG_DLLINSTALL = 0x00000004,
/// The file registration or unregistration exceeded the specified timeout. WinError is set to ERROR_TIMEOUT.
SPREG_TIMEOUT = 0x00000005,
///
/// File registration or unregistration failed for an unknown reason. WinError indicates an extended error code from the component.
///
SPREG_UNKNOWN = 0xFFFFFFFF,
}
/// List to which the source will be appended.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupAddToSourceListA")]
[Flags]
public enum SRCLIST : uint
{
///
/// The specified list is temporary and will be the only list accessible to the current process until
/// SetupCancelTemporarySourceList is called or SetSourceList is called again. Important: If a temporary list is set,
/// sources are not added to or deleted from the system or user lists, even if subsequent calls to SetupAddToSourceList or
/// SetupRemoveFromSourceList explicitly specify those lists.
///
SRCLIST_TEMPORARY = 0x00000001,
///
/// The user is not allowed to add or change sources when SetupPromptForDisk is used. This flag is typically used in combination
/// with the SRCLIST_TEMPORARY flag.
///
SRCLIST_NOBROWSE = 0x00000002,
/// Add the source to the per-system list. The caller must be an administrator.
SRCLIST_SYSTEM = 0x00000010,
/// Add the source to the per-user list.
SRCLIST_USER = 0x00000020,
///
/// If the caller is an administrator, the source is added to the per-system list; if the caller is not a member of the
/// administrators local group, the source is added to the per-user list for the current user.
///
///
/// Note If a temporary list is currently in use (see SetupSetSourceList), the preceding flags are ignored and the source
/// is added to the temporary list.
///
SRCLIST_SYSIFADMIN = 0x00000040,
/// Remove all subdirectories of the source.
SRCLIST_SUBDIRS = 0x00000100,
///
/// Add the source to the end of the list. If this flag is not specified, the source is added to the beginning of the list.
///
SRCLIST_APPEND = 0x00000200,
///
/// Normally, all paths are stripped of a platform-specific component if it is the final component. For example, a path stored
/// in the registry as f:\x86 is returned as f:. If this flag is specified, the platform-specific component is not stripped.
///
SRCLIST_NOSTRIPPLATFORM = 0x00000400,
}
/// Splits the provided value into its parts.
/// The value.
/// The type and modifier.
public static (DEVPROPTYPE type, DEVPROPTYPE mod) Split(this DEVPROPTYPE value) => (value & DEVPROPTYPE.DEVPROP_MASK_TYPE, value & DEVPROPTYPE.DEVPROP_MASK_TYPEMOD);
///
/// The CABINET_INFO structure stores information about a cabinet file. The SetupIterateCabinet function specifies this
/// structure as a parameter when it sends a SPFILENOTIFY_NEEDNEWCABINET notification to the cabinet callback routine.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-cabinet_info_a typedef struct _CABINET_INFO_A { PCSTR
// CabinetPath; PCSTR CabinetFile; PCSTR DiskName; USHORT SetId; USHORT CabinetNumber; } CABINET_INFO_A, *PCABINET_INFO_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._CABINET_INFO_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct CABINET_INFO
{
/// Path to the cabinet file.
[MarshalAs(UnmanagedType.LPTStr)]
public string CabinetPath;
/// Name of the cabinet file.
[MarshalAs(UnmanagedType.LPTStr)]
public string CabinetFile;
/// Name of the source media that contains the cabinet file.
[MarshalAs(UnmanagedType.LPTStr)]
public string DiskName;
/// Identifier of the current set. This number is generated by the software that builds the cabinet.
public ushort SetId;
///
/// Number of the cabinet. This number is generated by the software that builds the cabinet and is generally a zero- or 1-based
/// index indicating the ordinal of the position of the cabinet within a set.
///
public ushort CabinetNumber;
}
///
/// The FILE_IN_CABINET_INFO structure provides information about a file found in the cabinet. The SetupIterateCabinet
/// function sends this structure as one of the parameters when it sends a SPFILENOTIFY_FILEINCABINET notification to the cabinet
/// callback routine.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-file_in_cabinet_info_a typedef struct
// _FILE_IN_CABINET_INFO_A { PCSTR NameInCabinet; DWORD FileSize; DWORD Win32Error; WORD DosDate; WORD DosTime; WORD DosAttribs;
// CHAR FullTargetName[MAX_PATH]; } FILE_IN_CABINET_INFO_A, *PFILE_IN_CABINET_INFO_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._FILE_IN_CABINET_INFO_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct FILE_IN_CABINET_INFO
{
/// File name as it exists within the cabinet file.
[MarshalAs(UnmanagedType.LPTStr)]
public string NameInCabinet;
/// Uncompressed size of the file in the cabinet, in bytes.
public uint FileSize;
/// If an error occurs, this member is the system error code. If no error has occurred, it is NO_ERROR.
public Win32Error Win32Error;
/// Date that the file was last saved.
public ushort DosDate;
/// MS-DOS time stamp of the file in the cabinet.
public ushort DosTime;
/// Attributes of the file in the cabinet.
public ushort DosAttribs;
/// Target path and file name.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string FullTargetName;
}
///
/// The FILEPATHS structure stores source and target path information. The setup functions send the FILEPATHS
/// structure as a parameter in several of the notifications sent to callback routines. For more information, see Notifications.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-filepaths_a typedef struct _FILEPATHS_A { PCSTR Target;
// PCSTR Source; UINT Win32Error; DWORD Flags; } FILEPATHS_A, *PFILEPATHS_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._FILEPATHS_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct FILEPATHS
{
/// Path to the target file.
[MarshalAs(UnmanagedType.LPTStr)]
public string Target;
///
/// Path to the source file. This member is not used when the FILEPATHS structure is used with a file delete operation.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string Source;
/// If an error occurs, this member is the system error code. If no error has occurred, it is NO_ERROR.
public Win32Error Win32Error;
///
/// Additional information that depends on the notification sent with the FILEPATHS structure.
///
/// For SPFILENOTIFY_COPYERROR notifications, Flags specifies dialog box behavior and can be one of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// SP_COPY_NOBROWSE
/// Do not offer the user the option to browse.
///
/// -
/// SP_COPY_NOSKIP
/// Do not offer the user the option to skip the file.
///
/// -
/// SP_COPY_WARNIFSKIP
/// Inform the user that skipping the file may affect the installation.
///
///
///
/// For SPFILENOTIFY_FILEOPDELAYED notifications, Flags specifies the type of file operation delayed and can be one of
/// the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// FILEOP_COPY
/// A file copy operation was delayed.
///
/// -
/// FILEOP_DELETE
/// A file delete operation was delayed.
///
///
///
public uint Flags;
}
///
/// The FILEPATHS_SINGNERINFO structure stores source and target path information, and also file signature information. The
/// setup functions send FILEPATHS_SIGNERINFO as a parameter in several of the notifications sent to callback routines. For
/// more information, see Notifications.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-filepaths_signerinfo_a typedef struct
// _FILEPATHS_SIGNERINFO_A { PCSTR Target; PCSTR Source; UINT Win32Error; DWORD Flags; PCSTR DigitalSigner; PCSTR Version; PCSTR
// CatalogFile; } FILEPATHS_SIGNERINFO_A, *PFILEPATHS_SIGNERINFO_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._FILEPATHS_SIGNERINFO_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct FILEPATHS_SIGNERINFO
{
/// Path to the target file.
[MarshalAs(UnmanagedType.LPTStr)]
public string Target;
/// Path to the source file. This member is not used when the FILEPATHS structure is used with a file delete operation.
[MarshalAs(UnmanagedType.LPTStr)]
public string Source;
/// If an error occurs, this member is the system error code. If no error has occurred, it is NO_ERROR.
public Win32Error Win32Error;
///
/// Additional information that depends on the notification sent with the FILEPATHS_SIGNERINFO structure.
///
/// For SPFILENOTIFY_COPYERROR notifications, Flags specifies dialog box behavior and can be one of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// SP_COPY_NOBROWSE
/// Do not offer the user the option to browse.
///
/// -
/// SP_COPY_NOSKIP
/// Do not offer the user the option to skip the file.
///
/// -
/// SP_COPY_WARNIFSKIP
/// Inform the user that skipping the file may affect the installation.
///
///
///
/// For SPFILENOTIFY_FILEOPDELAYED notifications, Flags specifies the type of file operation delayed and can be one of
/// the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// FILEOP_COPY
/// A file copy operation was delayed.
///
/// -
/// FILEOP_DELETE
/// A file delete operation was delayed.
///
///
///
public uint Flags;
/// Digital signer of the file.
[MarshalAs(UnmanagedType.LPTStr)]
public string DigitalSigner;
/// Version of the file.
[MarshalAs(UnmanagedType.LPTStr)]
public string Version;
/// Catalog file.
[MarshalAs(UnmanagedType.LPTStr)]
public string CatalogFile;
}
/// Provides a handle to a device information set.
[StructLayout(LayoutKind.Sequential)]
public struct HDEVINFO : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HDEVINFO(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HDEVINFO NULL => new HDEVINFO(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HDEVINFO h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HDEVINFO(IntPtr h) => new HDEVINFO(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HDEVINFO h1, HDEVINFO h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HDEVINFO h1, HDEVINFO h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HDEVINFO h && handle == h.handle;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// Provides a handle to a disk-space list.
[StructLayout(LayoutKind.Sequential)]
public struct HDSKSPC : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HDSKSPC(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HDSKSPC NULL => new HDSKSPC(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HDSKSPC h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HDSKSPC(IntPtr h) => new HDSKSPC(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HDSKSPC h1, HDSKSPC h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HDSKSPC h1, HDSKSPC h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HDSKSPC h && handle == h.handle;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// Provides a handle to an open INF file.
[StructLayout(LayoutKind.Sequential)]
public struct HINF : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HINF(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HINF NULL => new HINF(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HINF h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HINF(IntPtr h) => new HINF(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HINF h1, HINF h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HINF h1, HINF h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HINF h && handle == h.handle;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// Provides a handle to a file queue.
[StructLayout(LayoutKind.Sequential)]
public struct HSPFILEQ : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HSPFILEQ(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HSPFILEQ NULL => new HSPFILEQ(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HSPFILEQ h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HSPFILEQ(IntPtr h) => new HSPFILEQ(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HSPFILEQ h1, HSPFILEQ h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HSPFILEQ h1, HSPFILEQ h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HSPFILEQ h && handle == h.handle;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
///
/// The INFCONTEXT structure stores context information that functions such as SetupGetLineText use to navigate INF files.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-infcontext typedef struct _INFCONTEXT { PVOID Inf; PVOID
// CurrentInf; UINT Section; UINT Line; } INFCONTEXT, *PINFCONTEXT;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._INFCONTEXT")]
[StructLayout(LayoutKind.Sequential)]
public struct INFCONTEXT
{
/// Handle to the INF file returned by .
public HINF Inf;
///
/// Pointer to the current INF file. The Inf member may point to multiple files if they were appended to the open INF
/// file using SetupOpenAppendInfFile.
///
public HINF CurrentInf;
/// Section in the current INF file.
public uint Section;
///
/// Line of the current section in the INF file.
///
/// Note The setup functions use this structure internally and it must not be accessed or modified by applications. It is
/// included here for informational purposes only.
///
///
public uint Line;
}
/// The SOURCE_MEDIA structure is used with the SPFILENOTIFY_NEEDMEDIA notification to pass source media information.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-source_media_a typedef struct _SOURCE_MEDIA_A { PCSTR
// Reserved; PCSTR Tagfile; PCSTR Description; PCSTR SourcePath; PCSTR SourceFile; DWORD Flags; } SOURCE_MEDIA_A, *PSOURCE_MEDIA_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SOURCE_MEDIA_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SOURCE_MEDIA
{
/// This member is not currently used.
[MarshalAs(UnmanagedType.LPTStr)]
public string Reserved;
/// Optional tag file that can be used to identify the source media.
[MarshalAs(UnmanagedType.LPTStr)]
public string Tagfile;
/// Human-readable description of the source media.
[MarshalAs(UnmanagedType.LPTStr)]
public string Description;
/// Path to the source that needs the new media.
[MarshalAs(UnmanagedType.LPTStr)]
public string SourcePath;
/// Source file to be retrieved from the new media.
[MarshalAs(UnmanagedType.LPTStr)]
public string SourceFile;
///
/// Copy style information that modifies how errors are handled. This member can be one or more of the following values.
/// SP_COPY_WARNIFSKIP
/// Inform the user that skipping the file may affect the installation.
/// SP_COPY_NOSKIP
/// Do not offer the user the option to skip the file.
/// SP_FLAG_CABINETCONTINUATION
/// The current source file is continued in another cabinet file.
/// SP_COPY_NOBROWSE
/// Do not offer the user the option to browse.
///
public CopyStyle Flags;
}
///
/// This structure is used to pass information for an alternate platform to SetupQueryInfOriginalFileInformation.
///
/// Setup implicitly uses the SP_ALTPLATFORM_INFO_V1 structure if USE_SP_ALTPLATFORM_INFO_V1 is set to 1 or if _WIN32_WINNT
/// is less than or equal to 0x500. This version is for use with Windows 2000.
///
///
/// Setup implicitly uses the SP_ALTPLATFORM_INFO_V2 structure if USE_SP_ALTPLATFORM_INFO_V1 is 0 or undefined and _WIN32_WINNT is
/// set to 0x501.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_altplatform_info_v1 typedef struct
// _SP_ALTPLATFORM_INFO_V1 { DWORD cbSize; DWORD Platform; DWORD MajorVersion; DWORD MinorVersion; WORD ProcessorArchitecture; WORD
// Reserved; } SP_ALTPLATFORM_INFO_V1, *PSP_ALTPLATFORM_INFO_V1;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_ALTPLATFORM_INFO_V1")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_ALTPLATFORM_INFO_V1
{
/// Size of this structure, in bytes.
public uint cbSize;
///
/// Operating system. This must be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// VER_PLATFORM_WIN32_WINDOWS
/// Legacy operating systems.
///
/// -
/// VER_PLATFORM_WIN32_NT
/// Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP, or Windows 2000.
///
///
///
public PlatformID Platform;
/// Major version of the operating system.
public uint MajorVersion;
/// Minor version of the operating system.
public uint MinorVersion;
///
/// Processor architecture. This must be PROCESSOR_ARCHITECTURE_INTEL, PROCESSOR_ARCHITECTURE_ALPHA,
/// PROCESSOR_ARCHITECTURE_IA64, PROCESSOR_ARCHITECTURE_ALPHA64.
///
public ProcessorArchitecture ProcessorArchitecture;
/// Must be set to zero.
public ushort Reserved;
}
///
/// The SP_ALTPLATFORM_INFO_V2 structure is used to pass information for an alternate platform to SetupQueryInfOriginalFileInformation.
///
/// Setup uses the SP_ALTPLATFORM_INFO_V2 structure if USE_SP_ALTPLATFORM_INFO_V1 is 0 or undefined and _WIN32_WINNT is set
/// to 0x501. FirstValidatedMajorVersion and FirstValidatedMinorVersion are only available with
/// SP_ALTPLATFORM_INFO_V2 and for use with Windows Server 2008, Windows Vista, Windows Server 2003, or Windows XP.
///
///
/// Setup uses the SP_ALTPLATFORM_INFO_V1 structure if USE_SP_ALTPLATFORM_INFO_V1 is set to 1 or if _WIN32_WINNT is less than or
/// equal to 0x500. FirstValidatedMajorVersion and FirstValidatedMinorVersion are not available with SP_ALTPLATFORM_INFO_V1.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_altplatform_info_v2 typedef struct
// _SP_ALTPLATFORM_INFO_V2 { DWORD cbSize; DWORD Platform; DWORD MajorVersion; DWORD MinorVersion; WORD ProcessorArchitecture; union
// { WORD Reserved; WORD Flags; } DUMMYUNIONNAME; DWORD FirstValidatedMajorVersion; DWORD FirstValidatedMinorVersion; }
// SP_ALTPLATFORM_INFO_V2, *PSP_ALTPLATFORM_INFO_V2;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_ALTPLATFORM_INFO_V2")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_ALTPLATFORM_INFO_V2
{
/// Size of this structure, in bytes.
public uint cbSize;
///
/// Operating system. This member must be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// VER_PLATFORM_WIN32_WINDOWS
/// Legacy operating systems.
///
/// -
/// VER_PLATFORM_WIN32_NT
/// Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP, or Windows 2000.
///
///
///
public PlatformID Platform;
/// Major version of the operating system.
public uint MajorVersion;
/// Minor version of the operating system.
public uint MinorVersion;
///
/// Processor architecture. This must be PROCESSOR_ARCHITECTURE_INTEL, PROCESSOR_ARCHITECTURE_ALPHA,
/// PROCESSOR_ARCHITECTURE_IA64, PROCESSOR_ARCHITECTURE_ALPHA64.
///
public ProcessorArchitecture ProcessorArchitecture;
///
/// For Windows Server 2008, Windows Vista, Windows Server 2003, or Windows XP, this member must be set to
/// SP_ALTPLATFORM_FLAGS_VERSION_RANGE to use FirstValidatedMajorVersion and FirstValidatedMinorVersion. This
/// member must be set to zero for Windows 2000.
///
public ushort Flags;
///
/// Major version of the oldest previous operating system for which this package's digital signature is valid. For example, if
/// the alternate platform is VER_PLATFORM_WIN32_NT, version 5.1, and you want a driver package signed with a 5.0 osattr to also
/// be valid, set MajorVersion to 5, MinorVersion to 1, FirstValidatedMajorVersion to 5, and
/// FirstValidatedMinorVersion 0. To validate packages signed for any previous operating system, specify 0 for these
/// fields. To only validate against the target alternate platform, specify the same values as those in the MajorVersion and
/// MinorVersion fields. Available with Windows XP or later only. The Flags member must be set to
/// SP_ALTPLATFORM_FLAGS_VERSION_RANGE to use FirstValidatedMajorVersion.
///
public uint FirstValidatedMajorVersion;
///
/// Minor version of the oldest previous operating system for which this package's digital signature is valid. For information
/// see FirstValidatedMajorVersion. Available with Windows Server 2003 or Windows XP. The Flags member must be set
/// to SP_ALTPLATFORM_FLAGS_VERSION_RANGE to use FirstValidatedMinorVersion.
///
public uint FirstValidatedMinorVersion;
}
/// Undocumented.
[PInvokeData("setupapi.h")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_ALTPLATFORM_INFO_V3
{
/// Size of this structure, in bytes.
public uint cbSize;
///
/// Operating system. This member must be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// VER_PLATFORM_WIN32_WINDOWS
/// Legacy operating systems.
///
/// -
/// VER_PLATFORM_WIN32_NT
/// Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP, or Windows 2000.
///
///
///
public PlatformID Platform;
/// Major version of the operating system.
public uint MajorVersion;
/// Minor version of the operating system.
public uint MinorVersion;
///
/// Processor architecture. This must be PROCESSOR_ARCHITECTURE_INTEL, PROCESSOR_ARCHITECTURE_ALPHA,
/// PROCESSOR_ARCHITECTURE_IA64, PROCESSOR_ARCHITECTURE_ALPHA64.
///
public ProcessorArchitecture ProcessorArchitecture;
///
/// For Windows Server 2008, Windows Vista, Windows Server 2003, or Windows XP, this member must be set to
/// SP_ALTPLATFORM_FLAGS_VERSION_RANGE to use FirstValidatedMajorVersion and FirstValidatedMinorVersion. This
/// member must be set to zero for Windows 2000.
///
public ushort Flags;
///
/// Major version of the oldest previous operating system for which this package's digital signature is valid. For example, if
/// the alternate platform is VER_PLATFORM_WIN32_NT, version 5.1, and you want a driver package signed with a 5.0 osattr to also
/// be valid, set MajorVersion to 5, MinorVersion to 1, FirstValidatedMajorVersion to 5, and
/// FirstValidatedMinorVersion 0. To validate packages signed for any previous operating system, specify 0 for these
/// fields. To only validate against the target alternate platform, specify the same values as those in the MajorVersion and
/// MinorVersion fields. Available with Windows XP or later only. The Flags member must be set to
/// SP_ALTPLATFORM_FLAGS_VERSION_RANGE to use FirstValidatedMajorVersion.
///
public uint FirstValidatedMajorVersion;
///
/// Minor version of the oldest previous operating system for which this package's digital signature is valid. For information
/// see FirstValidatedMajorVersion. Available with Windows Server 2003 or Windows XP. The Flags member must be set
/// to SP_ALTPLATFORM_FLAGS_VERSION_RANGE to use FirstValidatedMinorVersion.
///
public uint FirstValidatedMinorVersion;
///
/// specify non-zero value (e.g. VER_NT_WORKSTATION) in ProductType to use field, and/or specify SP_ALTPLATFORM_FLAGS_SUITE_MASK
/// in Flags to use SuiteMask field, which may be zero.
///
/// Product type and suite mask of alternate platform. Used to select matching decorated install sections within driver packages
/// that target specific product variants of the OS. For example, for only Server products with the Enterprise or Small Business
/// suite classification, use ProductType VER_NT_SERVER with SuiteMask VER_SUITE_ENTERPRISE and VER_SUITE_SMALLBUSINESS.
///
///
public byte ProductType;
///
/// specify non-zero value (e.g. VER_NT_WORKSTATION) in ProductType to use field, and/or specify SP_ALTPLATFORM_FLAGS_SUITE_MASK
/// in Flags to use SuiteMask field, which may be zero.
///
/// Product type and suite mask of alternate platform. Used to select matching decorated install sections within driver packages
/// that target specific product variants of the OS. For example, for only Server products with the Enterprise or Small Business
/// suite classification, use ProductType VER_NT_SERVER with SuiteMask VER_SUITE_ENTERPRISE and VER_SUITE_SMALLBUSINESS.
///
///
public ushort SuiteMask;
///
/// Build number of alternate platform. Used to select matching decorated install sections within driver packages that target a
/// minimal build number with the specified OS MajorVersion/MinorVersion. If no specific minimal build number targeting is
/// required, a value of zero should be specified. Note that this capability is only supported on certain builds of 10.0 and later.
///
public uint BuildNumber;
}
/// An SP_CLASSIMAGELIST_DATA structure describes a class image list.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_classimagelist_data typedef struct
// _SP_CLASSIMAGELIST_DATA { DWORD cbSize; HIMAGELIST ImageList; ULONG_PTR Reserved; } SP_CLASSIMAGELIST_DATA, *PSP_CLASSIMAGELIST_DATA;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_CLASSIMAGELIST_DATA")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_CLASSIMAGELIST_DATA
{
/// The size, in bytes, of the SP_CLASSIMAGE_DATA structure.
public uint cbSize;
/// A handle to the class image list.
public HIMAGELIST ImageList;
/// Reserved. For internal use only.
public IntPtr Reserved;
}
// SuiteMask
///
/// An SP_CLASSINSTALL_HEADER is the first member of any class install parameters structure. It contains the device installation
/// request code that defines the format of the rest of the install parameters structure.
///
///
///
/// When a component allocates a class install parameters structure, it typically initializes the header fields of the structure.
/// Such a component sets the InstallFunction member to the DIF code for the installation request and sets cbSize to
/// the size of the SP_CLASSINSTALL_HEADER structure. For example:
///
///
/// SP_REMOVEDEVICE_PARAMS RemoveDeviceParams; RemoveDeviceParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); RemoveDeviceParams.ClassInstallHeader.InstallFunction = DIF_REMOVE;
///
/// A component must set the InstallFunction member before passing a class install parameters structure to SetupDiSetClassInstallParams.
///
/// However, a component does not have to set this field when passing class install parameters to SetupDiGetClassInstallParams. This
/// function sets the InstallFunction member in the structure it passes back to the caller. It sets InstallFunction to
/// the DIF_XXX code for the currently active device installation request.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_classinstall_header typedef struct
// _SP_CLASSINSTALL_HEADER { DWORD cbSize; DI_FUNCTION InstallFunction; } SP_CLASSINSTALL_HEADER, *PSP_CLASSINSTALL_HEADER;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_CLASSINSTALL_HEADER")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_CLASSINSTALL_HEADER
{
/// The size, in bytes, of the SP_CLASSINSTALL_HEADER structure.
public uint cbSize;
///
/// The device installation request (DIF code) for the class install parameters structure.
///
/// DIF codes have the format DIF_XXX and are defined in Setupapi.h. See Device Installation Function Codes for a complete
/// description of DIF codes.
///
///
public DI_FUNCTION InstallFunction;
}
/// An SP_DETECTDEVICE_PARAMS structure corresponds to a DIF_DETECT installation request.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_detectdevice_params typedef struct
// _SP_DETECTDEVICE_PARAMS { SP_CLASSINSTALL_HEADER ClassInstallHeader; PDETECT_PROGRESS_NOTIFY DetectProgressNotify; PVOID
// ProgressNotifyParam; } SP_DETECTDEVICE_PARAMS, *PSP_DETECTDEVICE_PARAMS;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DETECTDEVICE_PARAMS")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_DETECTDEVICE_PARAMS
{
/// An install request header that contains the size of the header and the DIF code for the request. See SP_CLASSINSTALL_HEADER.
public SP_CLASSINSTALL_HEADER ClassInstallHeader;
///
/// A callback routine that displays a progress bar for the device detection operation. The callback routine is supplied by the
/// device installation component that sends the DIF_DETECT request.
///
public PDETECT_PROGRESS_NOTIFY DetectProgressNotify;
/// The opaque ProgressNotifyParam "handle" that the class installer passes to the progress callback routine.
public IntPtr ProgressNotifyParam;
}
/// An SP_DEVICE_INTERFACE_DATA structure defines a device interface in a device information set.
///
/// A SetupAPI function that takes an instance of the SP_DEVICE_INTERFACE_DATA structure as a parameter verifies whether the
/// cbSize member of the supplied structure is equal to the size, in bytes, of the structure. If the cbSize member is
/// not set correctly, the function will fail and set an error code of ERROR_INVALID_USER_BUFFER.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_device_interface_data typedef struct
// _SP_DEVICE_INTERFACE_DATA { DWORD cbSize; GUID InterfaceClassGuid; DWORD Flags; ULONG_PTR Reserved; } SP_DEVICE_INTERFACE_DATA, *PSP_DEVICE_INTERFACE_DATA;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DEVICE_INTERFACE_DATA")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_DEVICE_INTERFACE_DATA
{
/// The size, in bytes, of the SP_DEVICE_INTERFACE_DATA structure. For more information, see the Remarks section.
public uint cbSize;
/// The GUID for the class to which the device interface belongs.
public Guid InterfaceClassGuid;
///
/// Can be one or more of the following:
/// SPINT_ACTIVE
/// The interface is active (enabled).
/// SPINT_DEFAULT
/// The interface is the default interface for the device class.
/// SPINT_REMOVED
/// The interface is removed.
///
public SPINT Flags;
/// Reserved. Do not use.
public UIntPtr Reserved;
}
/// An SP_DEVICE_INTERFACE_DETAIL_DATA structure contains the path for a device interface.
///
/// An SP_DEVICE_INTERFACE_DETAIL_DATA structure identifies the path for a device interface in a device information set.
///
/// SetupDi Xxx functions that take an SP_DEVICE_INTERFACE_DETAIL_DATA structure as a parameter verify that the cbSize
/// member of the supplied structure is equal to the size, in bytes, of the structure. If the cbSize member is not set
/// correctly for an input parameter, the function will fail and set an error code of ERROR_INVALID_PARAMETER. If the cbSize
/// member is not set correctly for an output parameter, the function will fail and set an error code of ERROR_INVALID_USER_BUFFER.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_device_interface_detail_data_a typedef struct
// _SP_DEVICE_INTERFACE_DETAIL_DATA_A { DWORD cbSize; CHAR DevicePath[ANYSIZE_ARRAY]; } SP_DEVICE_INTERFACE_DETAIL_DATA_A, *PSP_DEVICE_INTERFACE_DETAIL_DATA_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DEVICE_INTERFACE_DETAIL_DATA_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_DEVICE_INTERFACE_DETAIL_DATA
{
///
/// The size, in bytes, of the SP_DEVICE_INTERFACE_DETAIL_DATA structure. For more information, see the following Remarks section.
///
public uint cbSize;
///
/// A NULL-terminated string that contains the device interface path. This path can be passed to Win32 functions such as CreateFile.
///
public char DevicePath;
/// A default value for this structure with the value set appropriately.
public static readonly SP_DEVICE_INTERFACE_DETAIL_DATA Default = new SP_DEVICE_INTERFACE_DETAIL_DATA { cbSize = IntPtr.Size == 4 ? 4U + (uint)Marshal.SystemDefaultCharSize : 8U };
}
/// An SP_DEVINFO_DATA structure defines a device instance that is a member of a device information set.
///
///
/// An SP_DEVINFO_DATA structure identifies a device in a device information set. For example, when Windows sends a
/// DIF_INSTALLDEVICE request to a class installer and co-installers, it includes a handle to a device information set and a pointer
/// to an SP_DEVINFO_DATA that specifies the particular device. In addition to DIF requests, this structure is also used in some
/// SetupDi Xxx functions.
///
///
/// SetupDi Xxx functions that take an SP_DEVINFO_DATA structure as a parameter verify that the cbSize member of the
/// supplied structure is equal to the size, in bytes, of the structure. If the cbSize member is not set correctly for an
/// input parameter, the function will fail and set an error code of ERROR_INVALID_PARAMETER. If the cbSize member is not set
/// correctly for an output parameter, the function will fail and set an error code of ERROR_INVALID_USER_BUFFER.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_devinfo_data typedef struct _SP_DEVINFO_DATA { DWORD
// cbSize; GUID ClassGuid; DWORD DevInst; ULONG_PTR Reserved; } SP_DEVINFO_DATA, *PSP_DEVINFO_DATA;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DEVINFO_DATA")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_DEVINFO_DATA
{
/// The size, in bytes, of the SP_DEVINFO_DATA structure. For more information, see the following Remarks section.
public uint cbSize;
/// The GUID of the device's setup class.
public Guid ClassGuid;
///
/// An opaque handle to the device instance (also known as a handle to the devnode).
///
/// Some functions, such as SetupDi Xxx functions, take the whole SP_DEVINFO_DATA structure as input to identify a device
/// in a device information set. Other functions, such as CM _Xxx functions like CM_Get_DevNode_Status, take this
/// DevInst handle as input.
///
///
public uint DevInst;
/// Reserved. For internal use only.
public IntPtr Reserved;
}
///
/// An SP_DEVINFO_LIST_DETAIL_DATA structure contains information about a device information set, such as its associated setup class
/// GUID (if it has an associated setup class).
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_devinfo_list_detail_data_w typedef struct
// _SP_DEVINFO_LIST_DETAIL_DATA_W { DWORD cbSize; GUID ClassGuid; HANDLE RemoteMachineHandle; WCHAR
// RemoteMachineName[SP_MAX_MACHINENAME_LENGTH]; } SP_DEVINFO_LIST_DETAIL_DATA_W, *PSP_DEVINFO_LIST_DETAIL_DATA_W;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DEVINFO_LIST_DETAIL_DATA_W")]
#if x64
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 8)]
#else
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
#endif
public struct SP_DEVINFO_LIST_DETAIL_DATA
{
/// The size, in bytes, of the SP_DEVINFO_LIST_DETAIL_DATA structure.
public uint cbSize;
///
/// The setup class GUID that is associated with the device information set or GUID_NULL if there is no associated setup class.
///
public Guid ClassGuid;
///
///
/// If the device information set is for a remote computer, this member is a configuration manager machine handle for the remote
/// computer. If the device information set is for the local computer, this member is NULL.
///
///
/// This is typically the parameter that components use to access the remote computer. The RemoteMachineName contains a
/// string, in case the component requires the name of the remote computer.
///
///
public HANDLE RemoteMachineHandle;
///
/// A NULL-terminated string that contains the name of the remote computer. If the device information set is for the local
/// computer, this member is an empty string.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = SP_MAX_MACHINENAME_LENGTH)]
public string RemoteMachineName;
}
///
/// An SP_DEVINSTALL_PARAMS structure contains device installation parameters associated with a particular device information
/// element or associated globally with a device information set.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_devinstall_params_a typedef struct
// _SP_DEVINSTALL_PARAMS_A { DWORD cbSize; DWORD Flags; DWORD FlagsEx; HWND hwndParent; PSP_FILE_CALLBACK InstallMsgHandler; PVOID
// InstallMsgHandlerContext; HSPFILEQ FileQueue; ULONG_PTR ClassInstallReserved; DWORD Reserved; CHAR DriverPath[MAX_PATH]; }
// SP_DEVINSTALL_PARAMS_A, *PSP_DEVINSTALL_PARAMS_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DEVINSTALL_PARAMS_A")]
#if x64
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 8)]
#else
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
#endif
public struct SP_DEVINSTALL_PARAMS
{
/// The size, in bytes, of the SP_DEVINSTALL_PARAMS structure.
public uint cbSize;
///
///
/// Flags that control installation and user interface operations. Some flags can be set before sending the device installation
/// request while other flags are set automatically during the processing of some requests. Flags can be a combination of
/// the following values.
///
///
/// The flag values are listed in groups: writable by device installation applications and installers, read-only (only set by
/// the OS), reserved, and obsolete. The first group lists flags that are writable:
///
/// DI_CLASSINSTALLPARAMS
///
/// Set to use the Class Install parameters. SetupDiSetClassInstallParams sets this flag when the caller specifies parameters
/// and clears the flag when the caller specifies a NULL parameters pointer.
///
/// DI_COMPAT_FROM_CLASS
///
/// Set to force SetupDiBuildDriverInfoList to build a device's list of compatible drivers from its class driver list instead of
/// the INF file.
///
/// DI_DRIVERPAGE_ADDED
///
/// Set by a class installer or co-installer if the installer supplies a page that replaces the system-supplied driver
/// properties page. If this flag is set, the operating system does not display the system-supplied driver page.
///
/// DI_DONOTCALLCONFIGMG
///
/// Set if the configuration manager should not be called to remove or reenumerate devices during the execution of certain
/// device installation functions (for example, SetupDiInstallDevice).
///
///
/// If this flag is set, device installation applications, class installers, and co-installers must not call the following functions:
///
///
/// CM_Reenumerate_DevNode CM_Reenumerate_DevNode_Ex CM_Query_And_Remove_SubTree CM_Query_And_Remove_SubTree_Ex CM_Setup_DevNode
/// CM_Setup_DevNode_Ex CM_Set_HW_Prof_Flags CM_Set_HW_Prof_Flags_Ex CM_Enable_DevNode CM_Enable_DevNode_Ex CM_Disable_DevNode CM_Disable_DevNode_Ex
///
/// DI_ENUMSINGLEINF
///
/// Set if installers and other device installation components should only search the INF file specified by
/// SP_DEVINSTALL_PARAMS. DriverPath. If this flag is set, DriverPath contains the path of a single INF file
/// instead of a path of a directory.
///
/// DI_INF_IS_SORTED
///
/// Set to indicate that the Select Device page should list drivers in the order in which they appear in the INF file, instead
/// of sorting them alphabetically.
///
/// DI_INSTALLDISABLED
///
/// Set if the device should be installed in a disabled state by default. To be recognized, this flag must be set before Windows
/// calls the default handler for the DIF_INSTALLDEVICE request.
///
/// DI_NEEDREBOOT
///
/// For NT-based operating systems, this flag is set if the device requires that the computer be restarted after device
/// installation or a device state change. A class installer or co-installer can set this flag at any time during device
/// installation, if the installer determines that a restart is necessary.
///
/// DI_NEEDRESTART
/// The same as DI_NEEDREBOOT.
/// DI_NOBROWSE
///
/// Set to disable browsing when the user is selecting an OEM disk path. A device installation application sets this flag to
/// constrain a user to only installing from the installation media location.
///
/// DI_NODI_DEFAULTACTION
///
/// Set if SetupDiCallClassInstaller should not perform any default action if the class installer returns ERR_DI_DO_DEFAULT or
/// there is not a class installer.
///
/// DI_NOFILECOPY
/// Set if device installation applications and components, such as SetupDiInstallDevice, should skip file copying.
/// DI_NOVCP
/// Set to disable creation of a new copy queue. Use the caller-supplied copy queue in SP_DEVINSTALL_PARAMS. FileQueue.
/// DI_NOWRITE_IDS
///
/// Set to prevent SetupDiInstallDevice from writing the INF-specified hardware IDs and compatible IDs to the device properties
/// for the device node (devnode). This flag should only be set for root-enumerated devices.
///
/// This flag overrides the DI_FLAGSEX_ALWAYSWRITEIDS flag.
/// DI_PROPERTIES_CHANGE
/// Set by Device Manager if a device's properties were changed, which requires an update of the installer's user interface.
/// DI_QUIETINSTALL
///
/// Set if the device installer functions must be silent and use default choices wherever possible. Class installers and
/// co-installers must not display any UI if this flag is set.
///
/// DI_RESOURCEPAGE_ADDED
///
/// Set by a class installer or co-installer if the installer supplies a page that replaces the system-supplied resource
/// properties page. If this flag is set, the operating system does not display the system-supplied resource page.
///
/// DI_SHOWOEM
///
/// Set to allow support for OEM disks. If this flag is set, the operating system presents a "Have Disk" button on the Select
/// Device page. This flag is set, by default, in system-supplied wizards.
///
/// DI_USECI_SELECTSTRINGS
/// Set if a class installer or co-installer supplied strings that should be used during SetupDiSelectDevice.
/// The following flags are read-only (only set by the OS):
/// DI_DIDCLASS
///
/// Set if SetupDiBuildDriverInfoList has already built a list of the drivers for this class of device. If this list has already
/// been built, it contains all the driver information and this flag is always set. SetupDiDestroyDriverInfoList clears this
/// flag when it deletes a list of drivers for a class.
///
/// This flag is read-only. Only the operating system sets this flag.
/// DI_DIDCOMPAT
///
/// Set if SetupDiBuildDriverInfoList has already built a list of compatible drivers for this device. If this list has already
/// been built, it contains all the driver information and this flag is always set. SetupDiDestroyDriverInfoList clears this
/// flag when it deletes a compatible driver list.
///
///
/// This flag is only set in device installation parameters that are associated with a particular device information element,
/// not in parameters for a device information set as a whole.
///
/// This flag is read-only. Only the operating system sets this flag.
/// DI_MULTMFGS
///
/// Set by SetupDiBuildDriverInfoList if a list of drivers for a device setup class contains drivers that are provided by
/// multiple manufacturers.
///
/// This flag is read-only. Only the operating system sets this flag.
/// The following flags are reserved:
/// DI_AUTOASSIGNRES
/// DI_DISABLED
/// DI_FORCECOPY
/// DI_GENERALPAGE_ADDED
/// DI_OVERRIDE_INFFLAGS
/// DI_SHOWALL
/// DI_SHOWCLASS
/// DI_SHOWCOMPAT
/// The following flags are obsolete:
/// DI_NOSELECTICONS
/// DI_PROPS_NOCHANGEUSAGE
///
public DI_FLAGS Flags;
///
///
/// Additional flags that provide control over installation and user interface operations. Some flags can be set before calling
/// the device installer functions while other flags are set automatically during the processing of some functions.
/// FlagsEx can be a combination of the following values.
///
///
/// The flag values are listed in groups: writable by device installation applications and installers, read-only (only set by
/// the OS), reserved, and obsolete.
///
/// The first group lists flags that are writable:
/// DI_FLAGSEX_ALLOWEXCLUDEDDRVS
/// If set, include drivers that were marked "Exclude From Select."
///
/// For example, if this flag is set, SetupDiSelectDevice displays drivers that have the Exclude From Select state and
/// SetupDiBuildDriverInfoList includes Exclude From Select drivers in the requested driver list.
///
///
/// A driver is "Exclude From Select" if either it is marked ExcludeFromSelect in the INF file or it is a driver for a
/// device whose whole setup class is marked NoInstallClass or NoUseClass in the class installer INF. Drivers for
/// PnP devices are typically "Exclude From Select"; PnP devices should not be manually installed. To build a list of driver
/// files for a PnP device a caller of SetupDiBuildDriverInfoList must set this flag.
///
/// DI_FLAGSEX_ALWAYSWRITEIDS
///
/// If set and the DI_NOWRITE_IDS flag is clear, always write hardware and compatible IDs to the device properties for the
/// devnode. This flag should only be set for root-enumerated devices.
///
/// DI_FLAGSEX_APPENDDRIVERLIST
///
/// If set, SetupDiBuildDriverInfoList appends a new driver list to an existing list. This flag is relevant when
/// searching multiple locations.
///
/// DI_FLAGSEX_DRIVERLIST_FROM_URL
///
/// If set, build the driver list from INF(s) retrieved from the URL that is specified in SP_DEVINSTALL_PARAMS.
/// DriverPath. If the DriverPath is an empty string, use the Windows Update website.
///
///
/// Currently, the operating system does not support URLs. Use this flag to direct SetupDiBuildDriverInfoList to search
/// the Windows Update website.
///
/// Do not set this flag if DI_QUIETINSTALL is set.
/// DI_FLAGSEX_EXCLUDE_OLD_INET_DRIVERS
///
/// If set, do not include old Internet drivers when building a driver list. This flag should be set any time that you are
/// building a list of potential drivers for a device. You can clear this flag if you are just getting a list of drivers
/// currently installed for a device.
///
/// DI_FLAGSEX_FILTERCLASSES
///
/// If set, SetupDiBuildClassInfoList will check for class inclusion filters. This means that a device will not be included in
/// the class list if its class is marked as NoInstallClass.
///
/// DI_FLAGSEX_FILTERSIMILARDRIVERS
///
/// (Windows XP and later.) If set, SetupDiBuildDriverInfoList includes "similar" drivers when building a class driver list. A
/// "similar" driver is one for which one of the hardware IDs or compatible IDs in the INF file partially (or completely)
/// matches one of the hardware IDs or compatible IDs of the hardware.
///
/// DI_FLAGSEX_INET_DRIVER
///
/// If set, the driver was obtained from the Internet. Windows will not use the device's INF to install future devices because
/// Windows cannot guarantee that it can retrieve the driver files again from the Internet.
///
/// DI_FLAGSEX_INSTALLEDDRIVER
///
/// (Windows XP and later.) If set, SetupDiBuildDriverInfoList includes only the currently installed driver when creating a list
/// of class drivers or device-compatible drivers.
///
/// DI_FLAGSEX_NO_DRVREG_MODIFY
///
/// Do not process the AddReg and DelReg entries for the device's hardware and software (driver) keys. That is,
/// the AddReg and DelReg entries in the INF file DDInstall and DDInstall .HW sections.
///
/// DI_FLAGSEX_POWERPAGE_ADDED
///
/// If set, an installer added their own page for the power properties dialog. The operating system will not display the
/// system-supplied power properties page. This flag is only relevant if the device supports power management.
///
/// DI_FLAGSEX_PROPCHANGE_PENDING
///
/// If set, the user made changes to one or more device property sheets. The property-page provider typically sets this flag.
///
///
/// When the user closes the device property sheet, Device Manager checks the DI_FLAGSEX_PROPCHANGE_PENDING flag. If it is set,
/// Device Manager clears this flag, sets the DI_PROPERTIES_CHANGE flag, and sends a DIF_PROPERTYCHANGE request to the
/// installers to notify them that something has changed.
///
/// DI_FLAGSEX_SETFAILEDINSTALL
///
/// Set if the installation failed. If this flag is set, the SetupDiInstallDevice function just sets the FAILEDINSTALL flag in
/// the device's ConfigFlags registry value. If DI_FLAGSEX_SETFAILEDINSTALL is set, co-installers must return NO_ERROR in
/// response to DIF_INSTALLDEVICE, while class installers must return NO_ERROR or ERROR_DI_DO_DEFAULT.
///
/// DI_FLAGSEX_USECLASSFORCOMPAT
///
/// Filter INF files on the device's setup class when building a list of compatible drivers. If a device's setup class is known,
/// setting this flag reduces the time that is required to build a list of compatible drivers when searching INF files that are
/// not precompiled. This flag is ignored if DI_COMPAT_FROM_CLASS is set.
///
/// The following flags are read-only; only the operating system sets these flags:
/// DI_FLAGSEX_CI_FAILED
/// Set by the operating system if a class installer failed to load or start. This flag is read-only.
/// DI_FLAGSEX_DIDCOMPATINFO
/// Windows has built a list of driver nodes that are compatible with the device. This flag is read-only.
/// DI_FLAGSEX_DIDINFOLIST
///
/// Windows has built a list of driver nodes that includes all the drivers that are listed in the INF files of the specified
/// setup class. If the specified setup class is NULL because the HDEVINFO set or device has no associated class, the
/// list includes all driver nodes from all available INF files. This flag is read-only.
///
/// DI_FLAGSEX_IN_SYSTEM_SETUP
/// If set, installation is occurring during initial system setup. This flag is read-only.
/// The following flags are reserved:
/// DI_FLAGSEX_BACKUPONREPLACE
/// DI_FLAGSEX_DEVICECHANGE
/// DI_FLAGSEX_OLDINF_IN_CLASSLIST
/// DI_FLAGSEX_PREINSTALLBACKUP
/// DI_FLAGSEX_USEOLDINFSEARCH
/// The following flags are obsolete:
/// DI_FLAGSEX_AUTOSELECTRANK0
/// DI_FLAGSEX_NOUIONQUERYREMOVE
///
public DI_FLAGSEX FlagsEx;
/// Window handle that will own the user interface dialogs related to this device.
public HWND hwndParent;
///
/// Callback used to handle events during file copying. An installer can use a callback, for example, to perform special
/// processing when committing a file queue.
///
public PSP_FILE_CALLBACK InstallMsgHandler;
/// Private data that is used by the InstallMsgHandler callback.
public IntPtr InstallMsgHandlerContext;
///
/// A handle to a caller-supplied file queue where file operations should be queued but not committed.
///
/// If you associate a file queue with a device information set (SetupDiSetDeviceInstallParams), you must disassociate the queue
/// from the device information set before you delete the device information set. If you fail to disassociate the file queue,
/// Windows cannot decrement its reference count on the device information set and cannot free the memory.
///
/// This queue is only used if the DI_NOVCP flag is set, indicating that file operations should be enqueued but not committed.
///
public HSPFILEQ FileQueue;
/// A pointer for class-installer data. Co-installers must not use this field.
public IntPtr ClassInstallReserved;
/// Reserved. For internal use only.
public uint Reserved;
/// This path is used by the SetupDiBuildDriverInfoList function.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string DriverPath;
}
///
/// An SP_DRVINFO_DATA structure contains information about a driver. This structure is a member of a driver information list that
/// can be associated with a particular device instance or globally with a device information set.
///
///
///
/// In SetupAPI.h, this structure equates to either SP_DRVINFO_DATA_V1 or SP_DRVINFO_DATA_V2, based on whether you include the
/// following line in your source code:
///
///
/// #define USE_SP_DRVINFO_DATA_V1 1
///
///
/// Define this identifier only if your component must run on Windows 98 or Millennium Edition, or on Windows NT. If your component
/// is run only in Windows 2000 and later versions of Windows, do not define the identifier. If the identifier is not defined,
/// SP_DRVINFO_DATA_V2 is used.
///
/// SP_DRVINFO_DATA_V1 does not contain DriverDate and DriverVersion members.
///
/// SetupDi Xxx functions that take an SP_DRVINFO_DATA structure as a parameter verify that the cbSize member of the
/// supplied structure is equal to the size, in bytes, of the structure. If the cbSize member is not set correctly for an
/// input parameter, the function will fail and set an error code of ERROR_INVALID_PARAMETER. If the cbSize member is not set
/// correctly for an output parameter, the function will fail and set an error code of ERROR_INVALID_USER_BUFFER.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_drvinfo_data_v2_a typedef struct _SP_DRVINFO_DATA_V2_A
// { DWORD cbSize; DWORD DriverType; ULONG_PTR Reserved; CHAR Description[LINE_LEN]; CHAR MfgName[LINE_LEN]; CHAR
// ProviderName[LINE_LEN]; FILETIME DriverDate; DWORDLONG DriverVersion; } SP_DRVINFO_DATA_V2_A, *PSP_DRVINFO_DATA_V2_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DRVINFO_DATA_V2_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_DRVINFO_DATA_V2
{
///
/// The size, in bytes, of the SP_DRVINFO_DATA structure. For more information, see the Remarks section in this topic.
///
public uint cbSize;
///
/// The type of driver represented by this structure. Must be one of the following values:
/// SPDIT_CLASSDRIVER
/// This structure represents a class driver.
/// SPDIT_COMPATDRIVER
/// This structure represents a compatible driver.
///
public SPDIT DriverType;
/// Reserved. For internal use only.
public IntPtr Reserved;
/// A NULL-terminated string that describes the device supported by this driver.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LINE_LEN)]
public string Description;
/// A NULL-terminated string that contains the name of the manufacturer of the device supported by this driver.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LINE_LEN)]
public string MfgName;
///
/// A NULL-terminated string giving the provider of this driver. This is typically the name of the organization that creates the
/// driver or INF file. ProviderName can be an empty string.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LINE_LEN)]
public string ProviderName;
///
/// Date of the driver. From the DriverVer entry in the INF file. See the INF DDInstall Section for more information
/// about the DriverVer entry.
///
public FILETIME DriverDate;
/// Version of the driver. From the DriverVer entry in the INF file.
public ulong DriverVersion;
}
/// An SP_DRVINFO_DETAIL_DATA structure contains detailed information about a particular driver information structure.
///
/// The hardware ID and compatible IDs for a device are specified in the INF Models section in the following order:
///
/// -
/// The first ID (if specified) is the hardware ID for the device.
///
/// -
/// The remaining IDs (if specified) are compatible IDs for the device.
///
///
///
/// When you parse the HardwareID buffer, you must ensure that you correctly determine the end of the data in the buffer. Be
/// aware that the buffer is not necessarily double NULL terminated.
///
///
/// For example, depending on how the list of hardware ID and compatible IDs are specified in the INF Models section, the
/// HardwareID buffer can resemble any of the following:
///
///
/// -
/// \0
///
/// -
/// <HWID>\0
///
/// -
/// <HWID>\0<COMPATID_1>\0...<COMPATID_N>\0\0
///
/// -
/// \0<COMPATID_1>\0...<COMPATID_N>\0\0
///
///
///
/// An algorithm to correctly parse this buffer must use the CompatIDsOffset and CompatIDsLength fields to extract the
/// hardware ID and compatible IDs, as shown in the following code example:
///
///
/// // parse the hardware ID, if it exists if (CompatIDsOffset > 1) { // Parse for hardware ID from index 0. // This is a single NULL-terminated string } // Parse the compatible IDs, if they exist if (CompatIDsLength > 0) { // Parse for list of compatible IDs from CompatIDsOffset. // This is a double NULL-terminated list of strings (i.e. MULTI-SZ) }
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_drvinfo_detail_data_a typedef struct
// _SP_DRVINFO_DETAIL_DATA_A { DWORD cbSize; FILETIME InfDate; DWORD CompatIDsOffset; DWORD CompatIDsLength; ULONG_PTR Reserved;
// CHAR SectionName[LINE_LEN]; CHAR InfFileName[MAX_PATH]; CHAR DrvDescription[LINE_LEN]; CHAR HardwareID[ANYSIZE_ARRAY]; }
// SP_DRVINFO_DETAIL_DATA_A, *PSP_DRVINFO_DETAIL_DATA_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DRVINFO_DETAIL_DATA_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_DRVINFO_DETAIL_DATA
{
/// The size, in bytes, of the SP_DRVINFO_DETAIL_DATA structure.
public uint cbSize;
/// Date of the INF file for this driver.
public FILETIME InfDate;
///
/// The offset, in characters, from the beginning of the HardwareID buffer where the CompatIDs list begins.
///
/// This value can also be used to determine whether there is a hardware ID that precedes the CompatIDs list. If this value is
/// greater than 1, the first string in the HardwareID buffer is the hardware ID. If this value is less than or equal to
/// 1, there is no hardware ID.
///
///
public uint CompatIDsOffset;
///
///
/// The length, in characters, of the CompatIDs list starting at offset CompatIDsOffset from the beginning of the
/// HardwareID buffer.
///
///
/// If CompatIDsLength is nonzero, the CompatIDs list contains one or more NULL-terminated strings with an additional
/// NULL character at the end of the list.
///
///
/// If CompatIDsLength is zero, the CompatIDs list is empty. In that case, there is no additional NULL character at the
/// end of the list.
///
///
public uint CompatIDsLength;
/// Reserved. For internal use only.
public IntPtr Reserved;
///
/// A NULL-terminated string that contains the name of the INF DDInstall section for this driver. This must be the basic
/// DDInstall section name, such as InstallSec, without any OS/architecture-specific extensions.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LINE_LEN)]
public string SectionName;
/// A NULL-terminated string that contains the full-qualified name of the INF file for this driver.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string InfFileName;
/// A NULL-terminated string that describes the driver.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LINE_LEN)]
public string DrvDescription;
///
///
/// A buffer that contains a list of IDs (a single hardware ID followed by a list of compatible IDs). These IDs correspond to
/// the hardware ID and compatible IDs in the INF Models section.
///
/// Each ID in the list is a NULL-terminated string.
///
/// If the hardware ID exists (that is, if CompatIDsOffset is greater than one), this single NULL-terminated string is
/// found at the beginning of the buffer.
///
///
/// If the CompatIDs list is not empty (that is, if CompatIDsLength is not zero), the CompatIDs list starts at offset
/// CompatIDsOffset from the beginning of this buffer, and is terminated with an additional NULL character at the end of
/// the list.
///
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)]
public string HardwareID;
}
///
/// An SP_DRVINSTALL_PARAMS structure contains driver installation parameters associated with a particular driver information element.
///
///
///
/// Starting with Windows 7, an installer or co-installer can set the DNF_REQUESTADDITIONALSOFTWARE flag to indicate that the driver
/// package requires additional software that may or not be installed in the computer.
///
///
/// After the driver package for the device is installed, the Plug and Play (PnP) manager performs the following steps if the
/// installer sets the DNF_REQUESTADDITIONALSOFTWARE flag:
///
///
/// -
///
/// The PnP manager generates a Problem Report and Solution (PRS) error report with the type of RequestAddtionalSoftware.
/// This report contains information about the specific hardware ID of the device and the system architecture of the computer.
///
///
/// -
///
/// If there is a solution that is provided by the independent hardware vendor (IHV) for the device-specific software, the solution
/// is downloaded to the computer.
///
///
/// -
///
/// If the device-specific software is not installed on the computer, the PnP manager presents the solution to the user and provides
/// a link to download the software. The user can then choose to download and install this software by following the instructions
/// presented in the solution.
///
///
///
///
/// Note The installer does not have to set the DNF_REQUESTADDITIONALSOFTWARE flag if the INF file for the driver package has
/// set the RequestAdditionalSoftware flag in the INF ControlFlags Section.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_drvinstall_params typedef struct _SP_DRVINSTALL_PARAMS
// { DWORD cbSize; DWORD Rank; DWORD Flags; DWORD_PTR PrivateData; DWORD Reserved; } SP_DRVINSTALL_PARAMS, *PSP_DRVINSTALL_PARAMS;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DRVINSTALL_PARAMS")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_DRVINSTALL_PARAMS
{
/// The size, in bytes, of the SP_DRVINSTALL_PARAMS structure.
public uint cbSize;
/// The rank match of this driver. Ranges from 0 to n, where 0 is the most compatible.
public uint Rank;
///
/// Flags that control functions operating on this driver. Can be a combination of the following:
/// DNF_ALWAYSEXCLUDEFROMLIST (Windows Vista and later versions of Windows)
///
/// If set, this flag prevents the driver node from being enumerated, regardless of the client that is performing the enumeration.
///
/// DNF_AUTHENTICODE_SIGNED (Windows Server 2003 and later versions of Windows)
/// This driver's INF file is signed by an Authenticode signature. This flag is read-only to installers.
/// For more information, see Using SetupAPI to Verify Driver Authenticode Signatures.
/// DNF_BAD_DRIVER
/// Do not use this driver. Installers can read and write this flag.
/// If this flag is set, SetupDiSelectBestCompatDrv and SetupDiSelectDevice ignore this driver.
///
/// A class installer or co-installer can set this flag to prevent Windows from listing the driver in the Select Driver dialog
/// box. An installer might set this flag when it handles a DIF_SELECTDEVICE or DIF_SELECTBESTCOMPATDRV request, for example.
///
/// DNF_BASIC_DRIVER (Windows XP and later versions of Windows)
/// This driver is a basic driver. This flag is read-only to installers.
/// DNF_CLASS_DRIVER
/// This driver is a class driver. This flag is read-only to installers.
/// DNF_COMPATIBLE_DRIVER
/// This driver is a compatible driver. This flag is read-only to installers.
/// DNF_DUPDESC
///
/// There are other providers supplying drivers that have the same description as this driver. This flag is read-only to installers.
///
/// DNF_DUPDRIVERVER (Windows XP and later versions of Windows)
/// There are other providers supplying drivers that have the same version as this driver. This flag is read-only to installers.
/// DNF_DUPPROVIDER
///
/// There are other providers supplying drivers that have the same description as this driver. The only difference between this
/// driver and its match is the driver date. This flag is read-only to installers.
///
///
/// If this flag is set, Windows displays the driver date and driver version next to the driver so that the user can distinguish
/// it from its match.
///
/// DNF_EXCLUDEFROMLIST
/// Do not display this driver in any driver-select dialogs.
/// DNF_INBOX_DRIVER (Windows Vista and later versions of Windows)
/// This driver node is derived from an INF file that was included with this version of Windows.
/// DNF_INET_DRIVER
/// This driver came from the Internet or from Windows Update. This flag is read-only to installers.
///
/// If you call SetupCopyOEMInf you must specify the SPOST_URL flag so that when Windows copies this INF into the
/// %SystemRoot%\inf directory Windows will mark it as an Internet INF. If you omit this step then Windows will attempt to use
/// this device to install other devices. The resulting problem is that Windows does not have the source files any longer and
/// will end up prompting the user with an invalid path.
///
/// DNF_INF_IS_SIGNED (Windows XP and later versions of Windows)
/// This flag is read-only to installers, and is set if any of the following conditions are true:
///
/// -
/// The driver has a WHQL release signature.
///
/// -
/// The driver is an inbox driver.
///
/// -
/// The driver has an Authenticode signature.
///
///
/// For more information, see
/// Driver Signing
/// .
/// DNF_INSTALLEDDRIVER (Windows Vista and later versions of Windows)
/// This driver node is currently installed for the device. This flag is read-only to installers.
/// DNF_LEGACYINF
///
/// This driver comes from a legacy INF file. This flag is valid only for the NT-based operating system. This flag is read-only
/// to installers.
///
/// DNF_NODRIVER
/// Set if no physical driver is to be installed for this logical driver.
/// DNF_OEM_F6_INF (Windows XP and later versions of Windows)
/// Reserved.
/// DNF_OLD_INET_DRIVER
///
/// This driver came from the Internet, but Windows does not currently have access to its source files. This flag is read-only
/// to installers.
///
///
/// The system will not install a driver marked with this flag because Windows does not have the source files and would end up
/// prompting the user with an invalid path. The INF for such a driver can be used for everything except for installing devices.
///
/// DNF_OLDDRIVER
/// This driver currently/previously controlled the associated device. This flag is read-only to installers.
/// DNF_REQUESTADDITIONALSOFTWARE (Windows 7 and later versions of Windows)
///
/// Set this flag if the driver package is only part of the software solution that is needed to operate the device. In this
/// case, the driver package requires the installation of additional software.
///
/// For more information, see the following Remarks section.
///
public DNF Flags;
/// A field a class installer can use to store private data. Co-installers should not use this field.
public IntPtr PrivateData;
/// Reserved. For internal use only.
public uint Reserved;
}
/// The SP_FILE_COPY_PARAMS structure describes a single file copy operation.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_file_copy_params_a typedef struct
// _SP_FILE_COPY_PARAMS_A { DWORD cbSize; HSPFILEQ QueueHandle; PCSTR SourceRootPath; PCSTR SourcePath; PCSTR SourceFilename; PCSTR
// SourceDescription; PCSTR SourceTagfile; PCSTR TargetDirectory; PCSTR TargetFilename; DWORD CopyStyle; HINF LayoutInf; PCSTR
// SecurityDescriptor; } SP_FILE_COPY_PARAMS_A, *PSP_FILE_COPY_PARAMS_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_FILE_COPY_PARAMS_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_FILE_COPY_PARAMS
{
///
/// Size of the structure, in bytes. Set to the value:
/// sizeof(SP_FILE_COPY_PARAMS)
/// .
///
public uint cbSize;
/// Handle to a setup file queue, as returned by SetupOpenFileQueue.
public HSPFILEQ QueueHandle;
/// Optional pointer to the root of the source for this copy, such as A:.
[MarshalAs(UnmanagedType.LPTStr)]
public string SourceRootPath;
/// Optional pointer to the path relative to SourceRootPath where the file can be found.
[MarshalAs(UnmanagedType.LPTStr)]
public string SourcePath;
/// File name part of the file to be copied.
[MarshalAs(UnmanagedType.LPTStr)]
public string SourceFilename;
/// Optional pointer to a description of the source media to be used during disk prompts.
[MarshalAs(UnmanagedType.LPTStr)]
public string SourceDescription;
///
/// Optional pointer to a tag file whose presence at SourceRootPath indicates the presence of the source media. If not
/// specified, the file itself will be used as the tag file if required.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string SourceTagfile;
/// Directory where the file is to be copied.
[MarshalAs(UnmanagedType.LPTStr)]
public string TargetDirectory;
///
/// Optional pointer to the name of the target file. If not specified, the target file will have the same name as the source file.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string TargetFilename;
///
/// Flags that control the behavior of the file copy operation. These flags may be a combination of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// SP_COPY_DELETESOURCE
/// Delete the source file upon successful copy. The caller is not notified if the deletion fails.
///
/// -
/// SP_COPY_REPLACEONLY
/// Copy the file only if doing so would overwrite a file at the destination path. The caller is not notified.
///
/// -
/// SP_COPY_NEWER_OR_SAME
///
/// Examine each file being copied to see if its version resources indicate that it is either the same version or not newer than
/// an existing copy on the target. The file version information used during version checks is that specified in the
/// dwFileVersionMS and dwFileVersionLS members of a VS_FIXEDFILEINFO structure, as filled in by the version functions. If one
/// of the files does not have version resources, or if they have identical version information, the source file is considered
/// newer. If the source file is not equal in version or newer, and CopyMsgHandler is specified, the caller is notified and may
/// cancel the copy. If CopyMsgHandler is not specified, the file is not copied.
///
///
/// -
/// SP_COPY_NEWER_ONLY
///
/// Examine each file being copied to see if its version resources indicate that it is not newer than an existing copy on the
/// target. If the source file is newer but not equal in version to the existing target, the file is copied.
///
///
/// -
/// SP_COPY_NOOVERWRITE
///
/// Check whether the target file exists, and if so, notify the caller who may veto the copy. If CopyMsgHandler is not
/// specified, the file is not overwritten.
///
///
/// -
/// SP_COPY_NODECOMP
///
/// Do not decompress the file. When this flag is set, the target file is not given the uncompressed form of the source name (if
/// appropriate). For example, copying f:\x86\cmd.ex_ to \\install\temp results in a target file of \\install\temp\cmd.ex_. If
/// the SP_COPY_NODECOMP flag was not specified, the file would be decompressed and the target would be called
/// \\install\temp\cmd.exe. The file name part of DestinationName, if specified, is stripped and replaced with the file name of
/// the source file. When SP_COPY_NODECOMP is specified, no language or version information can be checked.
///
///
/// -
/// SP_COPY_LANGUAGEAWARE
///
/// Examine each file being copied to see if its language differs from the language of any existing file already on the target.
/// If so, and CopyMsgHandler is specified, the caller is notified and may cancel the copy. If CopyMsgHandler is not specified,
/// the file is not copied.
///
///
/// -
/// SP_COPY_SOURCE_ABSOLUTE
/// SourceFile is a full source path. Do not look it up in the SourceDisksNames section of the INF file.
///
/// -
/// SP_COPY_SOURCEPATH_ABSOLUTE
///
/// SourcePathRoot is the full path part of the source file. Ignore the relative source specified in the SourceDisksNames
/// section of the INF file for the source media where the file is located. This flag is ignored if SP_COPY_SOURCE_ABSOLUTE is specified.
///
///
/// -
/// SP_COPY_FORCE_IN_USE
/// If the target exists, behave as if it is in-use and queue the file for copying on the next system reboot.
///
/// -
/// SP_COPY_IN_USE_NEEDS_REBOOT
/// If the file was in-use during the copy operation, alert the user that the system needs to be rebooted.
///
/// -
/// SP_COPY_NOSKIP
/// Do not give the user the option to skip a file.
///
/// -
/// SP_COPY_FORCE_NOOVERWRITE
/// Check whether the target file exists, and if so, the file is not overwritten. The caller is not notified.
///
/// -
/// SP_COPY_FORCE_NEWER
///
/// Examine each file being copied to see if its version resources (or time stamps for non-image files) indicate that it is not
/// newer than an existing copy on the target. If the file being copied is not newer, the file is not copied. The caller is not notified.
///
///
/// -
/// SP_COPY_WARNIFSKIP
///
/// If the user tries to skip a file, warn them that skipping a file may affect the installation. (Used for system-critical files.)
///
///
///
///
public CopyStyle CopyStyle;
/// Handle to the INF to use to obtain source information.
public HINF LayoutInf;
/// An optional Security Descriptor String specifying the ACL to apply to the file.
[MarshalAs(UnmanagedType.LPTStr)]
public string SecurityDescriptor;
}
///
/// The SP_INF_INFORMATION structure stores information about an INF file, including the style, number of constituent INF
/// files, and version data.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_inf_information typedef struct _SP_INF_INFORMATION {
// DWORD InfStyle; DWORD InfCount; BYTE VersionData[ANYSIZE_ARRAY]; } SP_INF_INFORMATION, *PSP_INF_INFORMATION;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_INF_INFORMATION")]
[VanaraMarshaler(typeof(SafeAnysizeStructMarshaler), nameof(InfCount))]
[StructLayout(LayoutKind.Sequential)]
public struct SP_INF_INFORMATION
{
///
/// Style of the INF file. This member can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// INF_STYLE_NONE
/// Specifies that the style of the INF file is unrecognized or nonexistent.
///
/// -
/// INF_STYLE_OLDNT
/// A legacy INF file format.
///
/// -
/// INF_STYLE_WIN4
/// A Windows INF file format.
///
///
///
public INF_STYLE InfStyle;
/// Number of constituent INF files.
public uint InfCount;
/// Stores information from the Version section of an INF file in an array of ANYSIZE_ARRAY bytes.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public byte[] VersionData;
}
/// The SP_INF_SIGNER_INFO structure stores information about an INF file's digital signature.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_inf_signer_info_v1_a typedef struct
// _SP_INF_SIGNER_INFO_V1_A { DWORD cbSize; CHAR CatalogFile[MAX_PATH]; CHAR DigitalSigner[MAX_PATH]; CHAR
// DigitalSignerVersion[MAX_PATH]; } SP_INF_SIGNER_INFO_V1_A, *PSP_INF_SIGNER_INFO_V1_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_INF_SIGNER_INFO_V1_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_INF_SIGNER_INFO_V1
{
/// Size of this structure, in bytes.
public uint cbSize;
/// Path to the catalog file, stored in an array of maximum size MAX_PATH characters.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string CatalogFile;
/// Path to the digital signer of the file, stored in an array of maximum size MAX_PATH characters.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string DigitalSigner;
/// Version of the digital signer, stored in an array of size MAX_PATH characters.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string DigitalSignerVersion;
}
/// The SP_INF_SIGNER_INFO structure stores information about an INF file's digital signature.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_inf_signer_info_v2_a typedef struct
// _SP_INF_SIGNER_INFO_V2_A { DWORD cbSize; CHAR CatalogFile[MAX_PATH]; CHAR DigitalSigner[MAX_PATH]; CHAR
// DigitalSignerVersion[MAX_PATH]; DWORD SignerScore; } SP_INF_SIGNER_INFO_V2_A, *PSP_INF_SIGNER_INFO_V2_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_INF_SIGNER_INFO_V2_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_INF_SIGNER_INFO_V2
{
/// Size of this structure, in bytes.
public uint cbSize;
/// Path to the catalog file, stored in an array of maximum size MAX_PATH characters.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string CatalogFile;
/// Path to the digital signer of the file, stored in an array of maximum size MAX_PATH characters.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string DigitalSigner;
/// Version of the digital signer, stored in an array of size MAX_PATH characters.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string DigitalSignerVersion;
///
public uint SignerScore;
}
///
/// An SP_NEWDEVICEWIZARD_DATA structure is used by installers to extend the operation of the hardware installation wizard by adding
/// custom pages. It is used with DIF_NEWDEVICEWIZARD_XXX installation requests.
///
/// SP_ADDPROPERTYPAGE_DATA is an alias for this structure.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_newdevicewizard_data typedef struct
// _SP_NEWDEVICEWIZARD_DATA { SP_CLASSINSTALL_HEADER ClassInstallHeader; DWORD Flags; HPROPSHEETPAGE
// DynamicPages[MAX_INSTALLWIZARD_DYNAPAGES]; DWORD NumDynamicPages; HWND hwndWizardDlg; } SP_NEWDEVICEWIZARD_DATA, *PSP_NEWDEVICEWIZARD_DATA;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_NEWDEVICEWIZARD_DATA")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_NEWDEVICEWIZARD_DATA
{
/// An install request header that contains the header size and the DIF code for the request. See SP_CLASSINSTALL_HEADER.
public SP_CLASSINSTALL_HEADER ClassInstallHeader;
/// Reserved. Must be zero.
public uint Flags;
/// An array of property sheet page handles. An installer can add the handles of custom wizard pages to this array.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_INSTALLWIZARD_DYNAPAGES)]
public HPROPSHEETPAGE[] DynamicPages;
///
/// The number of pages that are added to the DynamicPages array.
///
/// Because the array index is zero-based, this value is also the index to the next free entry in the array. For example, if
/// there are 3 pages in the array, DynamicPages[ 3 ] is the next entry for an installer to use.
///
///
public uint NumDynamicPages;
/// The handle to the top-level window of the hardware installation wizard .
public HWND hwndWizardDlg;
}
///
/// The SP_ORIGINAL_FILE_INFO structure receives the original INF file name and catalog file information returned by SetupQueryInfOriginalFileInformation.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_original_file_info_a typedef struct
// _SP_ORIGINAL_FILE_INFO_A { DWORD cbSize; CHAR OriginalInfName[MAX_PATH]; CHAR OriginalCatalogName[MAX_PATH]; }
// SP_ORIGINAL_FILE_INFO_A, *PSP_ORIGINAL_FILE_INFO_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_ORIGINAL_FILE_INFO_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_ORIGINAL_FILE_INFO
{
/// Size of this structure, in bytes.
public uint cbSize;
/// Original file name of the INF file stored in array of size MAX_PATH.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string OriginalInfName;
/// Catalog name of the INF file stored in array of size MAX_PATH.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string OriginalCatalogName;
}
/// An SP_POWERMESSAGEWAKE_PARAMS structure corresponds to a DIF_POWERMESSAGEWAKE installation request.
/// Windows only sends the DIF_POWERMESSAGEWAKE request if the drivers for the device support power management.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_powermessagewake_params_a typedef struct
// _SP_POWERMESSAGEWAKE_PARAMS_A { SP_CLASSINSTALL_HEADER ClassInstallHeader; CHAR *PowerMessageWake[LINE_LEN 2]; }
// SP_POWERMESSAGEWAKE_PARAMS_A, *PSP_POWERMESSAGEWAKE_PARAMS_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_POWERMESSAGEWAKE_PARAMS_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_POWERMESSAGEWAKE_PARAMS
{
/// An install request header that contains the header size and the DIF code for the request. See SP_CLASSINSTALL_HEADER.
public SP_CLASSINSTALL_HEADER ClassInstallHeader;
///
/// Buffer that contains a string of custom text. Windows displays this text on the power management page of the device
/// properties display in Device Manager.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LINE_LEN * 2)]
public string PowerMessageWake;
}
/// An SP_PROPCHANGE_PARAMS structure corresponds to a DIF_PROPERTYCHANGE installation request.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_propchange_params typedef struct _SP_PROPCHANGE_PARAMS
// { SP_CLASSINSTALL_HEADER ClassInstallHeader; DWORD StateChange; DWORD Scope; DWORD HwProfile; } SP_PROPCHANGE_PARAMS, *PSP_PROPCHANGE_PARAMS;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_PROPCHANGE_PARAMS")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_PROPCHANGE_PARAMS
{
/// An install request header that contains the header size and the DIF code for the request. See SP_CLASSINSTALL_HEADER.
public SP_CLASSINSTALL_HEADER ClassInstallHeader;
///
/// State change action. Can be one of the following values:
/// DICS_ENABLE
/// The device is being enabled.
/// For this state change, Windows enables the device if the DICS_FLAG_GLOBAL flag is specified.
///
/// If the DICS_FLAG_CONFIGSPECIFIC flag is specified and the current hardware profile is specified then Windows enables
/// the device. If the DICS_FLAG_CONFIGSPECIFIC is specified and not the current hardware profile then Windows sets some
/// flags in the registry and does not change the device's state. Windows will change the device state when the specified
/// profile becomes the current profile.
///
/// DICS_DISABLE
/// The device is being disabled.
/// For this state change, Windows disables the device if the DICS_FLAG_GLOBAL flag is specified.
///
/// If the DICS_FLAG_CONFIGSPECIFIC flag is specified and the current hardware profile is specified then Windows disables
/// the device. If the DICS_FLAG_CONFIGSPECIFIC is specified and not the current hardware profile then Windows sets some
/// flags in the registry and does not change the device's state.
///
/// DICS_PROPCHANGE
/// The properties of the device have changed.
///
/// For this state change, Windows ignores the Scope information as long it is a valid value, and stops and restarts the device.
///
/// DICS_START
/// The device is being started (if the request is for the currently active hardware profile).
/// DICS_START must be DICS_FLAG_CONFIGSPECIFIC. You cannot perform that change globally.
///
/// Windows only starts the device if the current hardware profile is specified. Otherwise, Windows sets a registry flag and
/// does not change the state of the device.
///
/// DICS_STOP
///
/// The device is being stopped. The driver stack will be unloaded and the CSCONFIGFLAG_DO_NOT_START flag will be set for the device.
///
/// DICS_STOP must be DICS_FLAG_CONFIGSPECIFIC. You cannot perform that change globally.
///
/// Windows only stops the device if the current hardware profile is specified. Otherwise, Windows sets a registry flag and does
/// not change the state of the device.
///
///
/// Components should not specify DICS_STOP or DICS_START. Instead, they should use DICS_PROPCHANGE to stop and restart a device
/// to cause changes in the device's configuration to take effect.
///
///
public DICS StateChange;
///
/// Flags that specify the scope of a device property change. Can be one of the following:
/// DICS_FLAG_GLOBAL
/// Make the change in all hardware profiles.
/// DICS_FLAG_CONFIGSPECIFIC
/// Make the change in the specified profile only.
/// The following flag is obsolete:
/// DICS_FLAG_CONFIGGENERAL
///
public DICS_FLAG Scope;
/// Supplies the hardware profile ID for profile-specific changes. Zero specifies the current hardware profile.
public uint HwProfile;
}
///
///
/// An SP_PROPSHEETPAGE_REQUEST structure can be passed as the first parameter (lpv) to the ExtensionPropSheetPageProc entry
/// point in the SetupAPI DLL. ExtensionPropSheetPageProc is used to retrieve a handle to a specified property sheet page.
///
/// For information about ExtensionPropSheetPageProc and related functions, see the Microsoft Windows SDK documentation.
///
///
///
/// The component that is retrieving the property pages calls SetupAPI's ExtensionPropSheetPageProc function and passes in a
/// pointer to a SP_PROPSHEETPAGE_REQUEST structure, the address of their AddPropSheetPageProc function, and some private
/// data. The property sheet provider calls the AddPropSheetPageProc routine for each property sheet it provides.
///
/// The following code excerpt shows how to retrieve one page, the SetupAPI's Resource Selection page:
///
/// { DWORD Err; HINSTANCE hLib; FARPROC PropSheetExtProc; HPROPSHEETPAGE hPages[2]; . . . if(!(hLib = GetModuleHandle(TEXT("setupapi.dll")))) { return GetLastError(); } if(!(PropSheetExtProc = GetProcAddress(hLib, "ExtensionPropSheetPageProc"))) { Err = GetLastError(); FreeLibrary(hLib); return Err; } PropPageRequest.cbSize = sizeof(SP_PROPSHEETPAGE_REQUEST); PropPageRequest.PageRequested = SPPSR_SELECT_DEVICE_RESOURCES; PropPageRequest.DeviceInfoSet = DeviceInfoSet; PropPageRequest.DeviceInfoData = DeviceInfoData; if(!PropSheetExtProc(&PropPageRequest, AddPropSheetPageProc, &hPages[1])) { Err = ERROR_INVALID_PARAMETER; FreeLibrary(hLib); return Err; } . . . }
///
/// The AddPropSheetPageProc for the previous excerpt would be something like the following:
///
/// BOOL CALLBACK AddPropSheetPageProc( IN HPROPSHEETPAGE hpage, IN LPARAM lParam ) { *((HPROPSHEETPAGE *)lParam) = hpage; return TRUE; }
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_propsheetpage_request typedef struct
// _SP_PROPSHEETPAGE_REQUEST { DWORD cbSize; DWORD PageRequested; HDEVINFO DeviceInfoSet; PSP_DEVINFO_DATA DeviceInfoData; }
// SP_PROPSHEETPAGE_REQUEST, *PSP_PROPSHEETPAGE_REQUEST;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_PROPSHEETPAGE_REQUEST")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_PROPSHEETPAGE_REQUEST
{
/// The size, in bytes, of the SP_PROPSHEETPAGE_REQUEST structure.
public uint cbSize;
///
/// The property sheet page to add to the property sheet. Can be one of the following values:
/// SPPSR_SELECT_DEVICE_RESOURCES
/// Specifies the Resource Selection page supplied by the SetupAPI DLL.
/// SPPSR_ENUM_BASIC_DEVICE_PROPERTIES
///
/// Specifies a page that is supplied by the device's BasicProperties32 provider. That is, an installer or other component that
/// supplied page(s) in response to a DIF_ADDPROPERTYPAGE_BASIC installation request.
///
/// SPPSR_ENUM_ADV_DEVICE_PROPERTIES
///
/// Specifies a page that is supplied by the class and/or the device's EnumPropPages32 provider. That is, an installer or other
/// component that supplied page(s) in response to a DIF_ADDPROPERTYPAGE_ADVANCED installation request.
///
///
public SPPSR PageRequested;
/// The handle for the device information set that contains the device being installed.
public HDEVINFO DeviceInfoSet;
/// A pointer to an SP_DEVINFO_DATA structure for the device being installed.
public IntPtr DeviceInfoData;
}
///
///
/// The SP_REGISTER_CONTROL_STATUS structure contains information about a file being registered or unregistered using the
/// RegisterDlls INF directive to self-register DLLs on Windows 2000.
///
///
/// When SetupInstallFromInfSection sends a SPFILENOTIFY_STARTREGISTRATION or SPFILENOTIFY_ENDREGISTRATION notification to the
/// callback routine, the caller must provide a pointer to a SP_REGISTER_CONTROL_STATUS structure in the MsgHandler parameter.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_register_control_statusa typedef struct
// _SP_REGISTER_CONTROL_STATUSA { DWORD cbSize; PCSTR FileName; DWORD Win32Error; DWORD FailureCode; } SP_REGISTER_CONTROL_STATUSA, *PSP_REGISTER_CONTROL_STATUSA;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_REGISTER_CONTROL_STATUSA")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_REGISTER_CONTROL_STATUS
{
///
public uint cbSize;
/// Fully qualified path of the file being registered or unregistered.
[MarshalAs(UnmanagedType.LPTStr)]
public string FileName;
///
/// For an SPFILENOTIFY_STARTREGISTRATION notification, this member is not used and should be set to NO_ERROR. For a
/// SPFILENOTIFY_ENDREGISTRATION notification, set to a system error code.
///
public Win32Error Win32Error;
///
///
/// For a SPFILENOTIFY_STARTREGISTRATION notification, this member is not used and should be set to SPREG_SUCCESS. For a
/// SPFILENOTIFY_ENDREGISTRATION notification, set to one of the following failure codes that indicate the result of registration.
///
///
///
/// Value
/// Meaning
///
/// -
/// SPREG_SUCCESS
/// The file was successfully registered or unregistered. WinError not used.
///
/// -
/// SPREG_LOADLIBRARY
/// LoadLibrary failed for the file. WinError contains an extended error code from the component.
///
/// -
/// SPREG_GETPROCADDR
/// GetProcAddress failed for the file. WinError contains an extended error code from the component.
///
/// -
/// SPREG_REGSVR
/// DLLRegisterServer entry point returned failure. WinError contains an extended error code from the component.
///
/// -
/// SPREG_DLLINSTALL
/// DLLInstall entry point returned failure. WinError contains an extended error code from the component.
///
/// -
/// SPREG_TIMEOUT
/// The file registration or unregistration exceeded the specified timeout. WinError is set to ERROR_TIMEOUT.
///
/// -
/// SPREG_UNKNOWN
///
/// File registration or unregistration failed for an unknown reason. WinError indicates an extended error code from the component.
///
///
///
///
public SPREG FailureCode;
}
/// An SP_REMOVEDEVICE_PARAMS structure corresponds to the DIF_REMOVE installation request.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_removedevice_params typedef struct
// _SP_REMOVEDEVICE_PARAMS { SP_CLASSINSTALL_HEADER ClassInstallHeader; DWORD Scope; DWORD HwProfile; } SP_REMOVEDEVICE_PARAMS, *PSP_REMOVEDEVICE_PARAMS;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_REMOVEDEVICE_PARAMS")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_REMOVEDEVICE_PARAMS
{
/// An install request header that contains the header size and the DIF code for the request. See SP_CLASSINSTALL_HEADER.
public SP_CLASSINSTALL_HEADER ClassInstallHeader;
///
/// Flags that indicate the scope of the device removal. Can be one of the following values:
/// DI_REMOVEDEVICE_GLOBAL
/// Make this change in all hardware profiles. Remove information about the device from the registry.
/// DI_REMOVEDEVICE_CONFIGSPECIFIC
///
/// Make this change to only the hardware profile specified by HwProfile. this flag only applies to root-enumerated
/// devices. When Windows removes the device from the last hardware profile in which it was configured, Windows performs a
/// global removal.
///
///
public DI_REMOVEDEVICE Scope;
/// The hardware profile ID for profile-specific changes. Zero specifies the current hardware profile.
public uint HwProfile;
}
/// An SP_SELECTDEVICE_PARAMS structure corresponds to a DIF_SELECTDEVICE installation request.
///
///
/// If an installer sets fields in this structure to be used during driver selection, the installer must also set the
/// DI_USECI_SELECTSTRINGS flag in the SP_DEVINSTALL_PARAMS.
///
/// The following screen shot shows a sample Select Device dialog box and identifies the strings an installer can supply.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_selectdevice_params_a typedef struct
// _SP_SELECTDEVICE_PARAMS_A { SP_CLASSINSTALL_HEADER ClassInstallHeader; CHAR Title[MAX_TITLE_LEN]; CHAR
// Instructions[MAX_INSTRUCTION_LEN]; CHAR ListLabel[MAX_LABEL_LEN]; CHAR SubTitle[MAX_SUBTITLE_LEN]; BYTE Reserved[2]; }
// SP_SELECTDEVICE_PARAMS_A, *PSP_SELECTDEVICE_PARAMS_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_SELECTDEVICE_PARAMS_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_SELECTDEVICE_PARAMS
{
/// An install request header that contains the header size and the DIF code for the request. See SP_CLASSINSTALL_HEADER.
public SP_CLASSINSTALL_HEADER ClassInstallHeader;
///
/// Buffer that contains an installer-provided window title for driver-selection windows. Windows uses this title for the window
/// title for the Select Device dialogs.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_TITLE_LEN)]
public string Title;
/// Buffer that contains an installer-provided select-device instructions.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_INSTRUCTION_LEN)]
public string Instructions;
/// Buffer that contains an installer-provided label for the list of drivers from which the user can select.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_LABEL_LEN)]
public string ListLabel;
///
/// Buffer that contains an installer-provided subtitle used in select-device wizards. This string is not used in select dialogs.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_SUBTITLE_LEN)]
public string SubTitle;
/// Reserved. For internal use only.
public ushort Reserved;
}
/// An SP_TROUBLESHOOTER_PARAMS structure corresponds to a DIF_TROUBLESHOOTER installation request.
/// An installer fills in this structure in response to a DIF_TROUBLESHOOTER request.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_troubleshooter_params_a typedef struct
// _SP_TROUBLESHOOTER_PARAMS_A { SP_CLASSINSTALL_HEADER ClassInstallHeader; CHAR ChmFile[MAX_PATH]; CHAR
// HtmlTroubleShooter[MAX_PATH]; } SP_TROUBLESHOOTER_PARAMS_A, *PSP_TROUBLESHOOTER_PARAMS_A;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_TROUBLESHOOTER_PARAMS_A")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct SP_TROUBLESHOOTER_PARAMS
{
/// An install request header that contains the header size and the DIF code for the request. See SP_CLASSINSTALL_HEADER.
public SP_CLASSINSTALL_HEADER ClassInstallHeader;
///
/// Optionally specifies a string buffer that contains the path of a CHM file. The CHM file contains HTML help topics with
/// troubleshooting information. The path must be fully qualified if the file is not in default system help directory (%SystemRoot%\help).
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string ChmFile;
///
/// Optionally specifies a string buffer that contains the path of a topic in the ChmFile. This parameter identifies the
/// page of the ChmFile that Windows should display first.
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string HtmlTroubleShooter;
}
/// An SP_UNREMOVEDEVICE_PARAMS structure corresponds to a DIF_UNREMOVE installation request.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/ns-setupapi-sp_unremovedevice_params typedef struct
// _SP_UNREMOVEDEVICE_PARAMS { SP_CLASSINSTALL_HEADER ClassInstallHeader; DWORD Scope; DWORD HwProfile; } SP_UNREMOVEDEVICE_PARAMS, *PSP_UNREMOVEDEVICE_PARAMS;
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_UNREMOVEDEVICE_PARAMS")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_UNREMOVEDEVICE_PARAMS
{
/// An install request header that contains the header size and the DIF code for the request. See SP_CLASSINSTALL_HEADER.
public SP_CLASSINSTALL_HEADER ClassInstallHeader;
/// A flag that indicates the scope of the unremove operation. This flag must always be set to DI_UNREMOVEDEVICE_CONFIGSPECIFIC.
public DI_UNREMOVEDEVICE Scope;
/// The hardware profile ID for profile-specific changes. Zero specifies the current hardware profile.
public uint HwProfile;
}
/// An SP_DEVICE_INTERFACE_DETAIL_DATA structure contains the path for a device interface.
///
/// An SP_DEVICE_INTERFACE_DETAIL_DATA structure identifies the path for a device interface in a device information set.
///
/// SetupDi Xxx functions that take an SP_DEVICE_INTERFACE_DETAIL_DATA structure as a parameter verify that the cbSize
/// member of the supplied structure is equal to the size, in bytes, of the structure. If the cbSize member is not set
/// correctly for an input parameter, the function will fail and set an error code of ERROR_INVALID_PARAMETER. If the cbSize
/// member is not set correctly for an output parameter, the function will fail and set an error code of ERROR_INVALID_USER_BUFFER.
///
///
[PInvokeData("setupapi.h", MSDNShortId = "NS:setupapi._SP_DEVICE_INTERFACE_DETAIL_DATA_A")]
public class SafeSP_DEVICE_INTERFACE_DETAIL_DATA : SafeMemoryHandle
{
/// Get an instance that represents the value.
public static readonly SafeSP_DEVICE_INTERFACE_DETAIL_DATA Null = new SafeSP_DEVICE_INTERFACE_DETAIL_DATA();
/// Initializes a new instance of the class.
/// The size of memory to allocate, in bytes.
public SafeSP_DEVICE_INTERFACE_DETAIL_DATA(SizeT size) : base(size)
{
Marshal.StructureToPtr(SP_DEVICE_INTERFACE_DETAIL_DATA.Default, handle, false);
}
private SafeSP_DEVICE_INTERFACE_DETAIL_DATA() : base(IntPtr.Zero, 0, false)
{
}
///
/// A NULL-terminated string that contains the device interface path. This path can be passed to Win32 functions such as CreateFile.
///
public string DevicePath => StringHelper.GetString(handle.Offset(4), CharSet.Auto, Size - 4);
}
}
}