using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.Extensions;
namespace Vanara.PInvoke
{
/// Items from the SetupAPI.dll
public static partial class SetupAPI
{
/// Severity of the message.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupLogErrorA")]
public enum LogSeverity
{
/// Information
LogSevInformation = 0x00000000,
/// Warning
LogSevWarning = 0x00000001,
/// Error
LogSevError = 0x00000002,
/// Fatal error
LogSevFatalError = 0x00000003,
}
/// Flags for .
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetDirectoryIdExA")]
[Flags]
public enum SETDIRID : uint
{
/// Indicate that the Directory does not specify a full path.
SETDIRID_NOT_FULL_PATH = 0x00000001
}
/// Indicates what information should be returned to the DataOut buffer.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueryFileLogA")]
public enum SetupFileLogInfo
{
/// Name of the source file as it exists on the source media
SetupFileLogSourceFilename,
/// A checksum value used by the system log
SetupFileLogChecksum,
/// Name of the tag file of the media source containing the source file
SetupFileLogDiskTagfile,
/// The human-readable description of the media where the source file resides
SetupFileLogDiskDescription,
/// Additional information associated with the logged file
SetupFileLogOtherInfo,
}
/// Flags for .
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupLogFileA")]
[Flags]
public enum SPLOGFILE : uint
{
///
/// Meaningful only for the system log and indicates that the file is not supplied by Microsoft. This parameter can be used to
/// convert an existing file's entry, such as when an OEM overwrites a Microsoft-supplied system file.
///
SPFILELOG_OEMFILE = 0x00000001,
}
/// Flags to combine to control the file queue scan operation.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupScanFileQueueA")]
[Flags]
public enum SPQ_SCAN : uint
{
/// Target files in the copy queue are already present on the target.
SPQ_SCAN_FILE_PRESENCE = 0x00000001,
///
/// Target files in the copy queue are already present on the target with valid signatures. Available with Windows 2000 and
/// later versions.
///
SPQ_SCAN_FILE_VALIDITY = 0x00000002,
///
/// Callback routine for each node of the queue. If the callback routine returns a nonzero value, the queue processing stops and
/// SetupScanFileQueue returns zero. Issue a SPFILENOTIFY_QUEUESCAN notification code and a pass a pointer to the target path as Param1.
///
SPQ_SCAN_USE_CALLBACK = 0x00000004,
///
/// Callback routine for each node of the queue. If the callback routine returns a nonzero value, the queue processing stops and
/// SetupScanFileQueue returns zero. Issue a SPFILENOTIFY_QUEUESCAN_EX notification and pass a pointer to a FILEPATHS structure
/// as Param1. SPQ_SCAN_USE_CALLBACKEX also checks that the file has a valid signature. Available starting with Windows 2000. On
/// Windows XP only, you can turn off signature checking by combining this flag with SPQ_SCAN_FILE_PRESENCE.
///
SPQ_SCAN_USE_CALLBACKEX = 0x00000008,
///
/// Flag specified when all files in the queue pass the check for valid signatures. SetupScanFileQueue informs the user that the
/// operation requires files that are already present on the target. This flag is ignored if SPQ_SCAN_FILE_PRESENCE or
/// SPQ_SCAN_FILE_VALIDITY is not specified. This flag may not be used with SPQ_SCAN_PRUNE_COPY_QUEUE or SPQ_SCAN_PRUNE_DELREN.
///
SPQ_SCAN_INFORM_USER = 0x00000010,
///
/// Combined with SPQ_SCAN_FILE_PRESENCE, removes present entries from the copy queue. When combined with
/// SPQ_SCAN_FILE_VALIDITY, removes signed entries from the copy queue. Available starting with Windows 2000. On Windows XP
/// only, files that are also specified in the delete queue or rename queues are not pruned unless SPQ_SCAN_PRUNE_DELREN is specified.
///
SPQ_SCAN_PRUNE_COPY_QUEUE = 0x00000020,
///
/// Available starting with Windows XP. Issues SPFILENOTIFY_QUEUESCAN_SIGNERINFO notification and passes a pointer to a
/// FILEPATHS_SIGNERINFO structure as Param1. Checks each file for a valid signature and reports signature information through
/// the callback function.
///
SPQ_SCAN_USE_CALLBACK_SIGNERINFO = 0x00000040,
///
/// Combined with SPQ_SCAN_FILE_PRESENCE or SPQ_SCAN_FILE_VALIDITY, removes entries in the delete or rename queue that are also
/// in the copy queue. When combined with SPQ_SCAN_PRUNE_COPY_QUEUE, limits files that are removed from the copy queue to files
/// that are not in the delete or rename queues. Available starting with Windows XP.
///
SPQ_SCAN_PRUNE_DELREN = 0x00000080,
///
SPQ_SCAN_FILE_PRESENCE_WITHOUT_SOURCE = 0x00000100,
///
SPQ_SCAN_FILE_COMPARISON = 0x00000200,
///
SPQ_SCAN_ACTIVATE_DRP = 0x00000400,
}
/// The controls for the installation of each service in the specified section.
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallServicesFromInfSectionA")]
[Flags]
public enum SPSVCINST : uint
{
/// AddService section: move the service tag to the front of its group order list.
SPSVCINST_TAGTOFRONT = 0x001,
/// AddService section: Mark this service as the function driver for the device being installed.
SPSVCINST_ASSOCSERVICE = 0x002,
/// DelService section: delete the event log entry.
SPSVCINST_DELETEEVENTLOGENTRY = 0x004,
/// AddService section: do not overwrite the display name if one already exists.
SPSVCINST_NOCLOBBER_DISPLAYNAME = 0x008,
/// AddService section: do not overwrite the start type value if the service already exists.
SPSVCINST_NOCLOBBER_STARTTYPE = 0x010,
/// AddService section: do not overwrite the error control value if the service already exists.
SPSVCINST_NOCLOBBER_ERRORCONTROL = 0x020,
/// AddService section: do not overwrite the load order group if it already exists.
SPSVCINST_NOCLOBBER_LOADORDERGROUP = 0x040,
/// AddService section: do not overwrite the dependencies list if it already exists.
SPSVCINST_NOCLOBBER_DEPENDENCIES = 0x080,
/// AddService section: mark this service as the function driver for the device being installed.
SPSVCINST_NOCLOBBER_DESCRIPTION = 0x100,
/// DelService section: Stop the associated service specified in the entry before deleting the service.
SPSVCINST_STOPSERVICE = 0x200,
///
/// AddService section: Security settings the service are overwritten if the service already exists in the system.
/// Note Available starting with Windows Server 2003 and Windows XP.
///
SPSVCINST_CLOBBER_SECURITY = 0x400,
///
/// AddService section: Start the service after the service is installed. This flag cannot be used to start a service that
/// implements a Plug and Play (PnP) function driver or filter driver for a device. Otherwise, this flag can be used to start a
/// user-mode or kernel-mode service that is managed by the Service Control Manager (SCM.)
/// Note Available starting with Windows Server 2008 and Windows Vista.
///
SPSVCINST_STARTSERVICE = 0x800,
///
/// AddService section: Do not overwrite the given service's required privileges if the service already exists in the system.
/// Note Available starting with Windows Server 2008 R2 and Windows 7.
///
SPSVCINST_NOCLOBBER_REQUIREDPRIVILEGES = 0x1000,
/// AddService section: don't overwrite triggers if they already exist.
SPSVCINST_NOCLOBBER_TRIGGERS = 0x00002000,
/// AddService section: don't overwrite service SID type if it already exists.
SPSVCINST_NOCLOBBER_SERVICESIDTYPE = 0x00004000,
/// AddService section: don't overwrite delayed auto start if it already exists.
SPSVCINST_NOCLOBBER_DELAYEDAUTOSTART = 0x00008000,
}
/// Flags for .
[Flags]
public enum SUOI : uint
{
///
/// The SetupUninstallOEMInf function first checks whether there are any devices installed using the .inf file. A device does
/// not need to be present to be detected as using the .inf file. If this flag is not set and the function finds a currently
/// installed device that was installed using this .inf file, the .inf file is not removed. If this flag is set, the .inf file
/// is removed whether the function finds a device that was installed with this .inf file.
///
SUOI_FORCEDELETE = 0x0001
}
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupInstallFileEx function installs a file as specified either by an INFCONTEXT returned by SetupFindXXXLine or
/// explicitly by the filename and path information. This function is the same as SetupInstallFile, except that a BOOL is
/// returned that indicates whether the file was in use.
///
/// If a file is copied, the caller of this function is required to have privileges to write into the target directory.
///
///
/// Optional pointer to the handle to an INF file that contains the SourceDisksNames and SourceDisksFiles sections. If
/// platform-specific sections exist for the user's system (for example, SourceDisksNames.x86 and SourceDisksFiles.x86), the
/// platform-specific section are used. If InfContext is not specified and CopyStyle includes SP_COPY_SOURCE_ABSOLUTE or
/// SP_COPY_SOURCEPATH_ABSOLUTE, InfHandle is ignored.
///
///
/// Optional pointer to context for a line in a Copy Files section in an INF file. The routine looks this file up in the
/// SourceDisksFiles section of InfHandle to get file copy information. If InfContext is not specified, SourceFile must be.
///
///
/// Optional pointer to the filename (no path) of the file to copy. The file is looked up in the SourceDisksFiles section. The
/// SourceFile parameter must be specified if InfContext is not. However, SourceFile is ignored if InfContext is specified.
///
///
/// Optional pointer to the root path for the file to be copied (for example, A:\ or F:). Paths in the SourceDisksNames section are
/// appended to this path. The SourcePathRoot parameter is ignored if CopyStyle includes the SP_COPY_SOURCE_ABSOLUTE flag.
///
///
/// Optional pointer to a new name for the copied file. If InfContext is specified, DestinationName supplies the filename only (no
/// path) of the target file. This parameter can be NULL to indicate that the target file should have the same name as the
/// source file. If InfContext is not specified, DestinationName supplies the full target path and filename for the target.
///
///
/// Flags that control the behavior of the file copy operation.
/// These flags can 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 delete fails.
///
/// -
/// SP_COPY_REPLACEONLY
/// Copy the file only if doing so overwrites a file at the destination path.
///
/// -
/// 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 newer or equal in version, 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 filename part of DestinationName, if specified, is stripped and replaced with the filename 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 requires a reboot.
///
/// -
/// 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.)
///
///
///
///
///
/// Optional pointer to a callback function to be notified of various conditions that may arise during the file copy.
///
/// Pointer to a caller-defined value that is passed as the first parameter of the callback function.
///
/// Pointer to a variable in which this function returns a flag that indicates whether the file was in use. This parameter is required.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
/// If GetLastError returns NO_ERROR, the file copy operation was not completed. The file may not have been copied because the file
/// copy operation was unnecessary or because the file callback function returned FALSE.
///
///
///
///
/// This API is typically used when installing new versions of system files that are likely to be in use. It updates a BOOL
/// value that indicates whether the file was in use. If the file was in use, then the file copy operation is postponed until the
/// system is rebooted.
///
///
/// If a UNC directory is specified as the target directory of a file installation, you must ensure it exists before you call
/// SetupInstallFileEx. The setup functions do not check for the existence of and do not create UNC directories. If the
/// target UNC directory does not exist, the file installation fails.
///
///
/// Note
///
/// The setupapi.h header defines SetupInstallFileEx as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupinstallfileexa WINSETUPAPI BOOL SetupInstallFileExA(
// HINF InfHandle, PINFCONTEXT InfContext, PCSTR SourceFile, PCSTR SourcePathRoot, PCSTR DestinationName, DWORD CopyStyle,
// PSP_FILE_CALLBACK_A CopyMsgHandler, PVOID Context, PBOOL FileWasInUse );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallFileExA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupInstallFileEx([In, Optional] HINF InfHandle, in INFCONTEXT InfContext, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceFile,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string SourcePathRoot, [Optional, MarshalAs(UnmanagedType.LPTStr)] string DestinationName, SP_COPY CopyStyle,
[Optional] PSP_FILE_CALLBACK CopyMsgHandler, [In, Optional] IntPtr Context, [MarshalAs(UnmanagedType.Bool)] out bool FileWasInUse);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupInstallFileEx function installs a file as specified either by an INFCONTEXT returned by SetupFindXXXLine or
/// explicitly by the filename and path information. This function is the same as SetupInstallFile, except that a BOOL is
/// returned that indicates whether the file was in use.
///
/// If a file is copied, the caller of this function is required to have privileges to write into the target directory.
///
///
/// Optional pointer to the handle to an INF file that contains the SourceDisksNames and SourceDisksFiles sections. If
/// platform-specific sections exist for the user's system (for example, SourceDisksNames.x86 and SourceDisksFiles.x86), the
/// platform-specific section are used. If InfContext is not specified and CopyStyle includes SP_COPY_SOURCE_ABSOLUTE or
/// SP_COPY_SOURCEPATH_ABSOLUTE, InfHandle is ignored.
///
///
/// Optional pointer to context for a line in a Copy Files section in an INF file. The routine looks this file up in the
/// SourceDisksFiles section of InfHandle to get file copy information. If InfContext is not specified, SourceFile must be.
///
///
/// Optional pointer to the filename (no path) of the file to copy. The file is looked up in the SourceDisksFiles section. The
/// SourceFile parameter must be specified if InfContext is not. However, SourceFile is ignored if InfContext is specified.
///
///
/// Optional pointer to the root path for the file to be copied (for example, A:\ or F:). Paths in the SourceDisksNames section are
/// appended to this path. The SourcePathRoot parameter is ignored if CopyStyle includes the SP_COPY_SOURCE_ABSOLUTE flag.
///
///
/// Optional pointer to a new name for the copied file. If InfContext is specified, DestinationName supplies the filename only (no
/// path) of the target file. This parameter can be NULL to indicate that the target file should have the same name as the
/// source file. If InfContext is not specified, DestinationName supplies the full target path and filename for the target.
///
///
/// Flags that control the behavior of the file copy operation.
/// These flags can 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 delete fails.
///
/// -
/// SP_COPY_REPLACEONLY
/// Copy the file only if doing so overwrites a file at the destination path.
///
/// -
/// 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 newer or equal in version, 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 filename part of DestinationName, if specified, is stripped and replaced with the filename 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 requires a reboot.
///
/// -
/// 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.)
///
///
///
///
///
/// Optional pointer to a callback function to be notified of various conditions that may arise during the file copy.
///
/// Pointer to a caller-defined value that is passed as the first parameter of the callback function.
///
/// Pointer to a variable in which this function returns a flag that indicates whether the file was in use. This parameter is required.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
/// If GetLastError returns NO_ERROR, the file copy operation was not completed. The file may not have been copied because the file
/// copy operation was unnecessary or because the file callback function returned FALSE.
///
///
///
///
/// This API is typically used when installing new versions of system files that are likely to be in use. It updates a BOOL
/// value that indicates whether the file was in use. If the file was in use, then the file copy operation is postponed until the
/// system is rebooted.
///
///
/// If a UNC directory is specified as the target directory of a file installation, you must ensure it exists before you call
/// SetupInstallFileEx. The setup functions do not check for the existence of and do not create UNC directories. If the
/// target UNC directory does not exist, the file installation fails.
///
///
/// Note
///
/// The setupapi.h header defines SetupInstallFileEx as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupinstallfileexa WINSETUPAPI BOOL SetupInstallFileExA(
// HINF InfHandle, PINFCONTEXT InfContext, PCSTR SourceFile, PCSTR SourcePathRoot, PCSTR DestinationName, DWORD CopyStyle,
// PSP_FILE_CALLBACK_A CopyMsgHandler, PVOID Context, PBOOL FileWasInUse );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallFileExA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupInstallFileEx([In, Optional] HINF InfHandle, [In, Optional] IntPtr InfContext, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceFile,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string SourcePathRoot, [Optional, MarshalAs(UnmanagedType.LPTStr)] string DestinationName, SP_COPY CopyStyle,
[Optional] PSP_FILE_CALLBACK CopyMsgHandler, [In, Optional] IntPtr Context, [MarshalAs(UnmanagedType.Bool)] out bool FileWasInUse);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupInstallFilesFromInfSection function queues all the files for an installation that are specified in the Copy
/// Files, Delete Files, and Rename Files sections that are listed by an Install section.
///
/// If a file is modified, the caller of this function is required to have privileges to write to the target directory.
///
/// The handle to an INF file that contains the section to be installed.
///
/// An optional pointer to a handle to the INF file that contains the SourceDisksFiles and SourceDisksNames sections.
/// If LayoutInfHandle is not specified, then the SourceDisksFiles and SourceDisksNames sections from InfHandle are used.
///
/// The handle to the queue where installation operations are to be added.
///
///
/// The name of the Install section in the InfHandle parameter that lists the Copy Files, Delete Files, and Rename Files sections
/// that contain the files to install.
///
/// Use a null-terminated string.
///
///
/// An optional pointer to a root path to the source files to copy, for example, A:\ or \pegasus\win\install.
/// Use a null-terminated string.
///
///
/// An optional pointer to a set of flags that control the behavior of the file copy operation.
/// The flags can be a combination of the following values.
/// SP_COPY_DELETESOURCE
/// Deletes the source file when the copy task succeeds.
/// The caller is not notified if a delete task fails.
/// SP_COPY_REPLACEONLY
/// Copies a file only to overwrite a file at the destination path.
/// SP_COPY_NEWER_OR_SAME
///
/// Examines each file that is copied to determine whether the version resources indicate that it is the same version, or not newer
/// than an existing copy on the target.
///
/// If the source file is not a newer or equal version, the function notifies the caller who can cancel the copy.
///
/// The file version information that is used during version checks is specified in the dwFileVersionMS and
/// dwFileVersionLS members of a VS_FIXEDFILEINFO structure, as filled in by the Win32 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.
///
/// SP_COPY_NEWER_ONLY
///
/// Examines each file that is being copied to determine whether 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
/// Checks to determine whether or not the target file exists.
/// If the target file exists, the function notifies the caller who can cancel the copy.
/// SP_COPY_NODECOMP
/// Does not decompress a file.
///
/// When this flag is set, the target file is not given the uncompressed form of the source name, for example, if you copy
/// f:\x86\cmd.ex_ to \install\temp the result is the following target file: \install\temp\cmd.ex_.
///
/// If the SP_COPY_NODECOMP flag is not specified, the file is decompressed and the target is called \install\temp\cmd.exe.
///
/// The filename part of DestinationName, if specified, is deleted and replaced with the filename of the source file. When
/// SP_COPY_NODECOMP is specified, language and version information cannot be checked.
///
/// SP_COPY_LANGUAGEAWARE
///
/// Examines each file that is being copied to determine whether or not the language is different from the language of any existing
/// file already on the target.
///
/// If the language is different, the function notifies the caller who can cancel the copy task.
/// 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 that is 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
/// Queues the file for copying on the next system reboot, if the target exists and is being used.
/// SP_COPY_IN_USE_NEEDS_REBOOT
/// Alerts the user that the system needs to be rebooted, if the file is being used during a copy operation.
/// SP_COPY_NOSKIP
/// Does not give the user the option to skip a file.
/// SP_COPY_FORCE_NOOVERWRITE
///
/// Checks to determine whether or not the target file exists, and if the target exists, the file is not overwritten and the caller
/// is not notified.
///
/// SP_COPY_FORCE_NEWER
///
/// Examines each file that is being copied to identify that 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 that is being copied is not newer, the file is not copied, and the caller is not notified.
/// SP_COPY_WARNIFSKIP
/// Warns that skipping a file may affect an installation if the user tries to skip a file.
/// Use this flag for system-critical files.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
///
///
///
/// SetupInstallFilesFromInfSection can be called multiple times to queue the files that are specified in multiple INF
/// sections. After the queue is committed successfully and the files are copied, renamed, and/or deleted,
/// SetupInstallFromInfSection can be called to perform registry and INI installation operations.
///
///
/// If a UNC directory is specified as the target directory of a file installation, you must ensure that the UNC directory exists
/// before you call SetupInstallFilesFromInfSection. The setup functions do not check for the existence of directories and do
/// not create UNC directories. If the target UNC directory does not exist, the file installation fails.
///
///
/// Note
///
/// The setupapi.h header defines SetupInstallFilesFromInfSection as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupinstallfilesfrominfsectiona WINSETUPAPI BOOL
// SetupInstallFilesFromInfSectionA( HINF InfHandle, HINF LayoutInfHandle, HSPFILEQ FileQueue, PCSTR SectionName, PCSTR
// SourceRootPath, UINT CopyFlags );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallFilesFromInfSectionA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupInstallFilesFromInfSection(HINF InfHandle, [In, Optional] HINF LayoutInfHandle, HSPFILEQ FileQueue,
[MarshalAs(UnmanagedType.LPTStr)] string SectionName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceRootPath, SP_COPY CopyFlags);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupInstallFromInfSection function carries out all the directives in an INF file Install section.
///
/// If the registry or file is modified, the caller of this function is required have privileges to write into the system or target directory.
///
///
///
/// Optional pointer to the window handle to the window that owns any dialog boxes that are generated during installation, such as
/// for disk prompting or file copying. If Owner is not specified, these dialog boxes become top-level windows.
///
/// Handle to the INF file that contains the section to be processed.
/// Name of the Install section in the INF file to process.
///
/// Controls what actions to perform. The flags can be a combination of the following values.
/// SPINST_INIFILES
/// Perform INI-file operations ( UpdateInis, UpdateIniFields lines in the Install section being processed).
/// SPINST_REGISTRY
/// Perform registry operations ( AddReg, DelReg lines in the Install section being processed).
/// SPINST_INI2REG
/// Perform INI-file to registry operations ( Ini2Reg lines in the Install section being processed).
/// SPINST_LOGCONFIG
/// This flag is only used when installing a device driver.
///
/// Perform logical configuration operations ( LogConf lines in the Install section being processed). This flag is
/// only used if DeviceInfoSet and DeviceInfoData are specified.
///
///
/// For more information about installing device drivers, LogConf, DeviceInfoSet, or DeviceInfoData, see the DDK Programmer's Guide.
///
/// SPINST_FILES
///
/// Perform file operations ( CopyFiles, DelFiles, RenFiles lines in the Install section being processed).
///
/// SPINST_ALL
/// Perform all installation operations.
/// SPINST_REGISTERCALLBACKAWARE
///
/// When using the RegisterDlls INF directive to self-register DLLs on Windows 2000, callers of
/// SetupInstallFromInfSection may receive notifications on each file as it is registered or unregistered. To send a
/// SPFILENOTIFY_STARTREGISTRATION or SPFILENOTIFY_ENDREGISTRATION notification to the callback routine, include
/// SPINST_REGISTERCALLBACKAWARE plus either SPINST_REGSVR or SPINST_UNREGSVR. The caller must also set the MsgHandler parameter.
///
/// SPINST_REGSVR
///
/// To send a notification to the callback routine when registering a file, include SPINST_REGISTERCALLBACKAWARE plus SPINST_REGSVR
/// in Flags. The caller must also specify the MsgHandler parameter.
///
/// SPINST_UNREGSVR
///
/// To send a notification to the callback routine when unregistering a file, include SPINST_REGISTERCALLBACKAWARE plus
/// SPINST_UNREGSVR in the Flags. The caller must also specify the MsgHandler parameter.
///
///
///
/// Optional parameter that must be specified if Flags includes SPINST_REGISTRY or SPINST_INI2REG. Handle to a registry key to be
/// used as the root when the INF file specifies HKR as the key. Note that this parameter is ignored if
/// SetupInstallFromInfSection is called with the optional DeviceInfoSet and DeviceInfoData set.
///
///
/// Source root for file copies. An example would be A:\ or \pegasus\win\install. If Flags includes SPINST_FILES, and SourceRootPath
/// is NULL, the system provides a default root path.
///
///
///
/// Optional parameter that must be specified if Flags includes SPINST_FILES. Specifies flags to be passed to the
/// SetupQueueCopySection function when files are queued for copy. These flags may be a combination of the following values.
///
/// SP_COPY_DELETESOURCE
/// Delete the source file upon successful copy. The caller is not notified if the delete fails.
/// SP_COPY_REPLACEONLY
/// Copy the file only if doing so would overwrite a file at the destination path.
/// 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 filename part of DestinationName, if specified, is stripped and replaced with the filename 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 inform the user that the system needs to be rebooted. This flag is only used
/// when later calling SetupPromptReboot or SetupScanFileQueue.
///
/// 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.)
///
///
///
///
/// Pointer to the callback routine. The callback routine must be in the format of FileCallback. See Notifications for more information.
///
///
/// This parameter is optional only if the Flags parameter does not include SPINST_FILES, SPINST_REGISTERCALLBACKAWARE plus
/// SPINST_REGSVR, or SPINST_UNREGSVR.
///
///
/// MsgHandler must be set if Flags includes SPINST_FILES. In this case, notification is sent to the callback routine when the file
/// queue is committed with SetupCommitFileQueue.
///
///
/// MsgHandler must be set if Flags includes SPINST_REGISTERCALLBACKAWARE plus SPINST_REGSVR or SPINST_UNREGSVR. In this case a
/// SPFILENOTIFY_STARTREGISTRATION or SPFILENOTIFY_ENDREGISTRATION is sent to the callback routine once each time a file is
/// registered or unregistered using the RegisterDlls INF directive on Windows 2000.
///
///
///
/// Value to be passed to the callback function when the file queue built by this routine internally is committed via
/// SetupCommitFileQueue. The Context parameter is optional only if the Flags parameter does not include SPINST_FIlLES. This
/// parameter must be specified if Flags includes SPINST_FIlLES.
///
///
/// Optional pointer to a handle to a device information set. For more information about the Device Installer setup functions, see
/// the DDK Programmer's Guide.
///
///
/// Optional pointer to a pointer to the SP_DEVINFO_DATA structure that provides a context to a specific element in the set
/// specified by DeviceInfoSet. For more information about the Device Installer setup functions, see the DDK Programmer's Guide.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// If a UNC directory is specified as the target directory of a file copy operation, you must ensure it exists before you call
/// SetupInstallFromInfSection. The setup functions do not check for the existence of and do not create UNC directories. If
/// the target UNC directory does not exist, the file installation will fail.
///
/// This function requires a Windows INF file. Some older INF file formats may not be supported.
///
/// Note
///
/// The setupapi.h header defines SetupInstallFromInfSection as an alias which automatically selects the ANSI or Unicode version of
/// this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code
/// that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupinstallfrominfsectiona WINSETUPAPI BOOL
// SetupInstallFromInfSectionA( HWND Owner, HINF InfHandle, PCSTR SectionName, UINT Flags, HKEY RelativeKeyRoot, PCSTR
// SourceRootPath, UINT CopyFlags, PSP_FILE_CALLBACK_A MsgHandler, PVOID Context, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA
// DeviceInfoData );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallFromInfSectionA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupInstallFromInfSection([In, Optional] HWND Owner, HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string SectionName,
SPINST Flags, [In, Optional] HKEY RelativeKeyRoot, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceRootPath, SP_COPY CopyFlags,
[In, Optional] PSP_FILE_CALLBACK MsgHandler, [In, Optional] IntPtr Context, [In, Optional] HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupInstallFromInfSection function carries out all the directives in an INF file Install section.
///
/// If the registry or file is modified, the caller of this function is required have privileges to write into the system or target directory.
///
///
///
/// Optional pointer to the window handle to the window that owns any dialog boxes that are generated during installation, such as
/// for disk prompting or file copying. If Owner is not specified, these dialog boxes become top-level windows.
///
/// Handle to the INF file that contains the section to be processed.
/// Name of the Install section in the INF file to process.
///
/// Controls what actions to perform. The flags can be a combination of the following values.
/// SPINST_INIFILES
/// Perform INI-file operations ( UpdateInis, UpdateIniFields lines in the Install section being processed).
/// SPINST_REGISTRY
/// Perform registry operations ( AddReg, DelReg lines in the Install section being processed).
/// SPINST_INI2REG
/// Perform INI-file to registry operations ( Ini2Reg lines in the Install section being processed).
/// SPINST_LOGCONFIG
/// This flag is only used when installing a device driver.
///
/// Perform logical configuration operations ( LogConf lines in the Install section being processed). This flag is
/// only used if DeviceInfoSet and DeviceInfoData are specified.
///
///
/// For more information about installing device drivers, LogConf, DeviceInfoSet, or DeviceInfoData, see the DDK Programmer's Guide.
///
/// SPINST_FILES
///
/// Perform file operations ( CopyFiles, DelFiles, RenFiles lines in the Install section being processed).
///
/// SPINST_ALL
/// Perform all installation operations.
/// SPINST_REGISTERCALLBACKAWARE
///
/// When using the RegisterDlls INF directive to self-register DLLs on Windows 2000, callers of
/// SetupInstallFromInfSection may receive notifications on each file as it is registered or unregistered. To send a
/// SPFILENOTIFY_STARTREGISTRATION or SPFILENOTIFY_ENDREGISTRATION notification to the callback routine, include
/// SPINST_REGISTERCALLBACKAWARE plus either SPINST_REGSVR or SPINST_UNREGSVR. The caller must also set the MsgHandler parameter.
///
/// SPINST_REGSVR
///
/// To send a notification to the callback routine when registering a file, include SPINST_REGISTERCALLBACKAWARE plus SPINST_REGSVR
/// in Flags. The caller must also specify the MsgHandler parameter.
///
/// SPINST_UNREGSVR
///
/// To send a notification to the callback routine when unregistering a file, include SPINST_REGISTERCALLBACKAWARE plus
/// SPINST_UNREGSVR in the Flags. The caller must also specify the MsgHandler parameter.
///
///
///
/// Optional parameter that must be specified if Flags includes SPINST_REGISTRY or SPINST_INI2REG. Handle to a registry key to be
/// used as the root when the INF file specifies HKR as the key. Note that this parameter is ignored if
/// SetupInstallFromInfSection is called with the optional DeviceInfoSet and DeviceInfoData set.
///
///
/// Source root for file copies. An example would be A:\ or \pegasus\win\install. If Flags includes SPINST_FILES, and SourceRootPath
/// is NULL, the system provides a default root path.
///
///
///
/// Optional parameter that must be specified if Flags includes SPINST_FILES. Specifies flags to be passed to the
/// SetupQueueCopySection function when files are queued for copy. These flags may be a combination of the following values.
///
/// SP_COPY_DELETESOURCE
/// Delete the source file upon successful copy. The caller is not notified if the delete fails.
/// SP_COPY_REPLACEONLY
/// Copy the file only if doing so would overwrite a file at the destination path.
/// 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 filename part of DestinationName, if specified, is stripped and replaced with the filename 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 inform the user that the system needs to be rebooted. This flag is only used
/// when later calling SetupPromptReboot or SetupScanFileQueue.
///
/// 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.)
///
///
///
///
/// Pointer to the callback routine. The callback routine must be in the format of FileCallback. See Notifications for more information.
///
///
/// This parameter is optional only if the Flags parameter does not include SPINST_FILES, SPINST_REGISTERCALLBACKAWARE plus
/// SPINST_REGSVR, or SPINST_UNREGSVR.
///
///
/// MsgHandler must be set if Flags includes SPINST_FILES. In this case, notification is sent to the callback routine when the file
/// queue is committed with SetupCommitFileQueue.
///
///
/// MsgHandler must be set if Flags includes SPINST_REGISTERCALLBACKAWARE plus SPINST_REGSVR or SPINST_UNREGSVR. In this case a
/// SPFILENOTIFY_STARTREGISTRATION or SPFILENOTIFY_ENDREGISTRATION is sent to the callback routine once each time a file is
/// registered or unregistered using the RegisterDlls INF directive on Windows 2000.
///
///
///
/// Value to be passed to the callback function when the file queue built by this routine internally is committed via
/// SetupCommitFileQueue. The Context parameter is optional only if the Flags parameter does not include SPINST_FIlLES. This
/// parameter must be specified if Flags includes SPINST_FIlLES.
///
///
/// Optional pointer to a handle to a device information set. For more information about the Device Installer setup functions, see
/// the DDK Programmer's Guide.
///
///
/// Optional pointer to a pointer to the SP_DEVINFO_DATA structure that provides a context to a specific element in the set
/// specified by DeviceInfoSet. For more information about the Device Installer setup functions, see the DDK Programmer's Guide.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// If a UNC directory is specified as the target directory of a file copy operation, you must ensure it exists before you call
/// SetupInstallFromInfSection. The setup functions do not check for the existence of and do not create UNC directories. If
/// the target UNC directory does not exist, the file installation will fail.
///
/// This function requires a Windows INF file. Some older INF file formats may not be supported.
///
/// Note
///
/// The setupapi.h header defines SetupInstallFromInfSection as an alias which automatically selects the ANSI or Unicode version of
/// this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code
/// that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupinstallfrominfsectiona WINSETUPAPI BOOL
// SetupInstallFromInfSectionA( HWND Owner, HINF InfHandle, PCSTR SectionName, UINT Flags, HKEY RelativeKeyRoot, PCSTR
// SourceRootPath, UINT CopyFlags, PSP_FILE_CALLBACK_A MsgHandler, PVOID Context, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA
// DeviceInfoData );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallFromInfSectionA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupInstallFromInfSection([In, Optional] HWND Owner, HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string SectionName,
SPINST Flags, [In, Optional] HKEY RelativeKeyRoot, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceRootPath, SP_COPY CopyFlags,
[In, Optional] PSP_FILE_CALLBACK MsgHandler, [In, Optional] IntPtr Context, [In, Optional] HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupInstallServicesFromInfSection function performs service installation and deletion operations that are specified
/// in the Service Install sections listed in the Service section of an INF file.
///
/// A caller of this function is required to have access to the Service Control Manager, and privileges to modify services.
///
/// A handle to the INF file that contains the Service section.
/// The name of the Service section to process. You should use a null-terminated string.
///
/// The controls for the installation of each service in the specified section.
///
///
/// Flag
/// Meaning
///
/// -
/// SPSVCINST_TAGTOFRONT 0x001
/// AddService section: move the service tag to the front of its group order list.
///
/// -
/// SPSVCINST_DELETEEVENTLOGENTRY 0x004
/// DelService section: delete the event log entry.
///
/// -
/// SPSVCINST_NOCLOBBER_DISPLAYNAME 0x008
/// AddService section: do not overwrite the display name if one already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_STARTTYPE 0x010
/// AddService section: do not overwrite the start type value if the service already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_ERRORCONTROL 0x020
/// AddService section: do not overwrite the error control value if the service already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_LOADORDERGROUP 0x040
/// AddService section: do not overwrite the load order group if it already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_DEPENDENCIES 0x080
/// AddService section: do not overwrite the dependencies list if it already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_DESCRIPTION 0x100
/// AddService section: mark this service as the function driver for the device being installed.
///
/// -
/// SPSVCINST_STOPSERVICE 0x200
/// DelService section: Stop the associated service specified in the entry before deleting the service.
///
/// -
/// SPSVCINST_CLOBBER_SECURITY 0x400
/// AddService section: Security settings the service are overwritten if the service already exists in the system.
///
/// -
/// SPSVCINST_STARTSERVICE 0x800
///
/// AddService section: Start the service after the service is installed. This flag cannot be used to start a service that
/// implements a Plug and Play (PnP) function driver or filter driver for a device. Otherwise, this flag can be used to start a
/// user-mode or kernel-mode service that is managed by the Service Control Manager (SCM.)
///
///
/// -
/// SPSVCINST_NOCLOBBER_REQUIREDPRIVILEGES 0x1000
/// AddService section: Do not overwrite the given service's required privileges if the service already exists in the system.
///
///
///
///
///
/// If the function succeeds, the return value is nonzero. The function calls SetLastError with ERROR_SUCCESS_REBOOT_REQUIRED
/// if a reboot of the system is required.
///
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupInstallServicesFromInfSection as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupinstallservicesfrominfsectiona WINSETUPAPI BOOL
// SetupInstallServicesFromInfSectionA( HINF InfHandle, PCSTR SectionName, DWORD Flags );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallServicesFromInfSectionA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupInstallServicesFromInfSection(HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string SectionName, SPSVCINST Flags);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupInstallServicesFromInfSectionEx function performs service installation and deletion operations that are
/// specified in the Service Install sections listed in the Service section of an INF file.
///
/// A caller of this function is required to have access to the Service Control Manager, and privileges to modify services.
///
/// A handle to the INF file that contains the Service section.
/// The name of the Service section to process. You should use a null-terminated string.
///
/// The controls for the installation.
///
///
/// Flag
/// Meaning
///
/// -
/// SPSVCINST_TAGTOFRONT 0x001
/// Move the service tag to the front of its group order list.
///
/// -
/// SPSVCINST_ASSOCSERVICE 0x002
/// AddService section: Mark this service as the function driver for the device being installed.
///
/// -
/// SPSVCINST_DELETEEVENTLOGENTRY 0x004
/// Delete the event log entry for a specified service.
///
/// -
/// SPSVCINST_NOCLOBBER_DISPLAYNAME 0x008
/// Do not overwrite the display name if one already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_STARTTYPE 0x010
/// Do not overwrite the start type value if the service already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_ERRORCONTROL 0x020
/// Do not overwrite the error control value if the service already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_LOADORDERGROUP 0x040
/// Do not overwrite the load order group if it already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_DEPENDENCIES 0x080
/// Do not overwrite the dependencies list if it already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_DESCRIPTION 0x100
/// AddService section: mark this service as the function driver for the device being installed.
///
/// -
/// SPSVCINST_STOPSERVICE 0x200
/// DelService section: Stop the associated service specified in the entry before deleting the service.
///
/// -
/// SPSVCINST_CLOBBER_SECURITY 0x400
/// AddService section: Security settings the service are overwritten if the service already exists in the system.
///
/// -
/// SPSVCINST_STARTSERVICE 0x800
///
/// AddService section: Start the service after the service is installed. This flag cannot be used to start a service that
/// implements a Plug and Play (PnP) function driver or filter driver for a device. Otherwise, this flag can be used to start a
/// user-mode or kernel-mode service that is managed by the Service Control Manager (SCM.)
///
///
/// -
/// SPSVCINST_NOCLOBBER_REQUIREDPRIVILEGES 0x1000
/// AddService section: Do not overwrite the given service's required privileges if the service already exists in the system.
///
///
///
///
///
/// An optional pointer to a handle to a device information set. For more information, see the DDK Programmer's Guide. (This
/// resource may not be available in some languages
///
/// and countries.)
///
///
///
/// An optional pointer to the SP_DEVINFO_DATA structure that provides a context to a specific element in the set that
/// DeviceInfoSet specifies. For more information, see the DDK Programmer's Guide. (This resource may not be available in some languages
///
/// and countries.)
///
/// Reserved.
/// Reserved.
///
///
/// If the function succeeds, the return value is nonzero. The function calls SetLastError with ERROR_SUCCESS_REBOOT_REQUIRED
/// if a reboot of the system is required.
///
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupInstallServicesFromInfSectionEx as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupinstallservicesfrominfsectionexa WINSETUPAPI BOOL
// SetupInstallServicesFromInfSectionExA( HINF InfHandle, PCSTR SectionName, DWORD Flags, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA
// DeviceInfoData, PVOID Reserved1, PVOID Reserved2 );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallServicesFromInfSectionExA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupInstallServicesFromInfSectionEx(HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string SectionName, SPSVCINST Flags,
[In, Optional] HDEVINFO DeviceInfoSet, in SP_DEVINFO_DATA DeviceInfoData, [In, Optional] IntPtr Reserved1, [In, Optional] IntPtr Reserved2);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupInstallServicesFromInfSectionEx function performs service installation and deletion operations that are
/// specified in the Service Install sections listed in the Service section of an INF file.
///
/// A caller of this function is required to have access to the Service Control Manager, and privileges to modify services.
///
/// A handle to the INF file that contains the Service section.
/// The name of the Service section to process. You should use a null-terminated string.
///
/// The controls for the installation.
///
///
/// Flag
/// Meaning
///
/// -
/// SPSVCINST_TAGTOFRONT 0x001
/// Move the service tag to the front of its group order list.
///
/// -
/// SPSVCINST_ASSOCSERVICE 0x002
/// AddService section: Mark this service as the function driver for the device being installed.
///
/// -
/// SPSVCINST_DELETEEVENTLOGENTRY 0x004
/// Delete the event log entry for a specified service.
///
/// -
/// SPSVCINST_NOCLOBBER_DISPLAYNAME 0x008
/// Do not overwrite the display name if one already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_STARTTYPE 0x010
/// Do not overwrite the start type value if the service already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_ERRORCONTROL 0x020
/// Do not overwrite the error control value if the service already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_LOADORDERGROUP 0x040
/// Do not overwrite the load order group if it already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_DEPENDENCIES 0x080
/// Do not overwrite the dependencies list if it already exists.
///
/// -
/// SPSVCINST_NOCLOBBER_DESCRIPTION 0x100
/// AddService section: mark this service as the function driver for the device being installed.
///
/// -
/// SPSVCINST_STOPSERVICE 0x200
/// DelService section: Stop the associated service specified in the entry before deleting the service.
///
/// -
/// SPSVCINST_CLOBBER_SECURITY 0x400
/// AddService section: Security settings the service are overwritten if the service already exists in the system.
///
/// -
/// SPSVCINST_STARTSERVICE 0x800
///
/// AddService section: Start the service after the service is installed. This flag cannot be used to start a service that
/// implements a Plug and Play (PnP) function driver or filter driver for a device. Otherwise, this flag can be used to start a
/// user-mode or kernel-mode service that is managed by the Service Control Manager (SCM.)
///
///
/// -
/// SPSVCINST_NOCLOBBER_REQUIREDPRIVILEGES 0x1000
/// AddService section: Do not overwrite the given service's required privileges if the service already exists in the system.
///
///
///
///
///
/// An optional pointer to a handle to a device information set. For more information, see the DDK Programmer's Guide. (This
/// resource may not be available in some languages
///
/// and countries.)
///
///
///
/// An optional pointer to the SP_DEVINFO_DATA structure that provides a context to a specific element in the set that
/// DeviceInfoSet specifies. For more information, see the DDK Programmer's Guide. (This resource may not be available in some languages
///
/// and countries.)
///
/// Reserved.
/// Reserved.
///
///
/// If the function succeeds, the return value is nonzero. The function calls SetLastError with ERROR_SUCCESS_REBOOT_REQUIRED
/// if a reboot of the system is required.
///
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupInstallServicesFromInfSectionEx as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupinstallservicesfrominfsectionexa WINSETUPAPI BOOL
// SetupInstallServicesFromInfSectionExA( HINF InfHandle, PCSTR SectionName, DWORD Flags, HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA
// DeviceInfoData, PVOID Reserved1, PVOID Reserved2 );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallServicesFromInfSectionExA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupInstallServicesFromInfSectionEx(HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string SectionName, SPSVCINST Flags,
[In, Optional] HDEVINFO DeviceInfoSet, [In, Optional] IntPtr DeviceInfoData, [In, Optional] IntPtr Reserved1, [In, Optional] IntPtr Reserved2);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupIterateCabinet function iterates through all the files in a cabinet and sends a notification to a callback
/// function for each file found.
///
///
/// Cabinet (.CAB) file to iterate through.
/// Not currently used.
///
/// Pointer to a FileCallback routine that will process the notifications SetupIterateCabinet returns as it iterates through
/// the files in the cabinet file. The callback routine may then return a value specifying whether to decompress, copy, or skip the file.
///
///
/// Context value that is passed into the routine specified in MsgHandler. This enables the callback routine to track values between
/// notifications, without having to use global variables.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupIterateCabinet as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupiteratecabineta WINSETUPAPI BOOL
// SetupIterateCabinetA( PCSTR CabinetFile, DWORD Reserved, PSP_FILE_CALLBACK_A MsgHandler, PVOID Context );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupIterateCabinetA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupIterateCabinet([MarshalAs(UnmanagedType.LPTStr)] string CabinetFile, [Optional] uint Reserved,
PSP_FILE_CALLBACK MsgHandler, IntPtr Context);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupLogError function writes an error message to a log file. It is meant to be used during the installation of
/// Windows, but it is always available. It is not intended to be used after the operating system is installed — the event log
/// should be used instead.
///
///
///
/// Pointer to the string that should be saved to Setup's log. The message must end with a return-linefeed combination (\r\n). You
/// should use a null-terminated string. The null-terminated string should not exceed the size of the destination buffer. The
/// message is always saved to the action log, setupact.log. If Severity is LogSevWarning, LogSevError, or
/// LogSevFatalError, Setup also saves the message to the error log, setuperr.log. Both logs are stored in the Windows directory.
///
///
/// Severity of the message, one of the following: LogSevInformation, LogSevWarning, LogSevError, or LogSevFatalError.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// -
/// The action log is intended for recording all modifications made to the system during installation of Windows.
///
/// -
/// The error log is intended for errors during installation of Windows only.
///
/// -
/// The MessageString parameter may be formatted further by Setup (though it does no additional processing now).
///
/// -
/// The error log will be presented to the user at the end of system setup.
///
///
///
/// Note
///
/// The setupapi.h header defines SetupLogError as an alias which automatically selects the ANSI or Unicode version of this function
/// based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setuplogerrora WINSETUPAPI BOOL SetupLogErrorA( LPCSTR
// MessageString, LogSeverity Severity );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupLogErrorA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupLogError([MarshalAs(UnmanagedType.LPTStr)] string MessageString, LogSeverity Severity);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupLogFile function adds an entry to the log file.
///
///
/// Handle to the file log as returned by SetupInitializeFileLog. The caller must not have passed SPFILELOG_QUERYONLY when the log
/// file was initialized.
///
///
/// Optional pointer to the name for a logical grouping of names within the log file. You should use a null-terminated
/// string. Required if SPFILELOG_SYSTEMLOG was not passed when the file log was initialized. Otherwise, this parameter can be NULL.
///
///
/// Name of the file as it exists on the source media from which it was installed. This name should be in whatever format is
/// meaningful to the caller. You should use a null-terminated string.
///
///
/// Name of the file as it exists on the target. This name should be in whatever format is meaningful to the caller. You should use
/// a null-terminated string.
///
/// Optional pointer to a checksum value. Required for the system log.
///
/// Optional pointer to the tagfile for the media from which the file was installed. You should use a null-terminated string.
/// The null-terminated string should not exceed the size of the destination buffer. Ignored for the system log if
/// SPFILELOG_OEMFILE is not specified. Required for the system log if SPFILELOG_OEMFILE is specified. Otherwise, this parameter can
/// be NULL.
///
///
/// Optional pointer to the human-readable description of the media from which the file was installed. You should use a
/// null-terminated string. Ignored for the system log if SPFILELOG_OEMFILE is not specified in the Flags parameter. Required
/// for the system log if SPFILELOG_OEMFILE is specified in the Flags parameter. Otherwise, this parameter can be NULL.
///
///
/// Optional pointer to additional information to be associated with the file. You should use a null-terminated string. This
/// parameter can be NULL.
///
///
/// This parameter can be SPFILELOG_OEMFILE, which is meaningful only for the system log and indicates that the file is not supplied
/// by Microsoft. This parameter can be used to convert an existing file's entry, such as when an OEM overwrites a
/// Microsoft-supplied system file.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupLogFile as an alias which automatically selects the ANSI or Unicode version of this function
/// based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setuplogfilea WINSETUPAPI BOOL SetupLogFileA( HSPFILELOG
// FileLogHandle, PCSTR LogSectionName, PCSTR SourceFilename, PCSTR TargetFilename, DWORD Checksum, PCSTR DiskTagfile, PCSTR
// DiskDescription, PCSTR OtherInfo, DWORD Flags );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupLogFileA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupLogFile(HSPFILELOG FileLogHandle, [Optional, MarshalAs(UnmanagedType.LPTStr)] string LogSectionName,
[MarshalAs(UnmanagedType.LPTStr)] string SourceFilename, [MarshalAs(UnmanagedType.LPTStr)] string TargetFilename, uint Checksum,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string DiskTagfile, [Optional, MarshalAs(UnmanagedType.LPTStr)] string DiskDescription,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string OtherInfo, SPLOGFILE Flags);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupOpenAppendInfFile function appends the information in an INF file to an INF file previously opened by SetupOpenInfFile.
///
///
///
/// If not NULL, FileName points to a null-terminated string containing the name (and optionally the path) of the INF
/// file to be opened. If the filename does not contain path separator characters, it is searched for, first in the %windir%\inf
/// directory, and then in the %windir%\system32 directory. If the filename contains path separator characters, it is assumed to be
/// a full path specification and no further processing is performed on it. If FileName is NULL, the INF filename is
/// retrieved from the LayoutFile value of the Version section in the existing INF file. The same search logic is applied to
/// the filename retrieved from the LayoutFile key.
///
/// Existing INF handle to which this INF file will be appended.
///
/// Optional pointer to a variable to which this function returns the (1-based) line number where an error occurred during loading
/// of the INF file. This value is generally reliable only if GetLastError does not return ERROR_NOT_ENOUGH_MEMORY. If an
/// out-of-memory condition does occur, ErrorLine may be 0.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
/// If FileName was not specified and there was no LayoutFile value in the Version section of the existing INF File,
/// GetLastError returns ERROR_INVALID_DATA.
///
///
///
///
/// This function requires a Windows INF file. Some older INF file formats may not be supported. In this case, the function returns
/// FALSE and GetLastError will return ERROR_INVALID_PARAMETER. The main purpose of this function is to combine an INF file
/// with the source file location information contained in the file specified in the LayoutFile entry of the Version section
/// (typically, LAYOUT.INF).
///
/// The ERROR_WRONG_INF_STYLE may also be returned by SetupOpenAppendInfFile if the INF file uses an older format.
///
/// Note
///
/// The setupapi.h header defines SetupOpenAppendInfFile as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupopenappendinffilea WINSETUPAPI BOOL
// SetupOpenAppendInfFileA( PCSTR FileName, HINF InfHandle, PUINT ErrorLine );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupOpenAppendInfFileA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupOpenAppendInfFile([Optional, MarshalAs(UnmanagedType.LPTStr)] string FileName, HINF InfHandle, out uint ErrorLine);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupOpenFileQueue function creates a setup file queue.
///
///
/// If the function succeeds, it returns a handle to a setup file queue. If there is not enough memory to create the queue, the
/// function returns INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
///
///
/// After the file queue has been committed and is no longer needed, SetupCloseFileQueue should be called to release the resources
/// allocated during SetupOpenFileQueue.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupopenfilequeue WINSETUPAPI HSPFILEQ SetupOpenFileQueue();
[DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupOpenFileQueue")]
public static extern SafeHSPFILEQ SetupOpenFileQueue();
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupOpenInfFile function opens an INF file and returns a handle to it.
///
///
/// Pointer to a null-terminated string containing the name (and optional path) of the INF file to be opened. If the filename does
/// not contain path separator characters, it is searched for, first in the %windir%\inf directory, and then in the
/// %windir%\system32 directory. If the filename contains path separator characters, it is assumed to be a full path specification
/// and no further processing is performed on it.
///
///
/// Optional pointer to a null-terminated string containing the class of INF file desired. This string must match the Class value of
/// the Version section (for example, Class=Net). If there is no entry in the Class value, but there is an entry for
/// ClassGUID in the Version section, the corresponding class name for that GUID is retrieved and used for the comparison.
///
///
/// Style of INF file to open or search for. This parameter can be a combination of the following flags.
/// INF_STYLE_OLDNT
/// A legacy INF file format.
/// INF_STYLE_WIN4
/// A Windows INF file format.
///
///
/// Optional pointer to a variable to which this function returns the (1-based) line number where an error occurred during loading
/// of the INF file. This value is generally reliable only if GetLastError does not return ERROR_NOT_ENOUGH_MEMORY. If an
/// out-of-memory condition does occur, ErrorLine may be 0.
///
///
/// The function returns a handle to the opened INF file if it is successful. Otherwise, the return value is INVALID_HANDLE_VALUE.
/// Extended error information can be retrieved by a call to GetLastError.
///
///
///
/// If the load fails because the INF file type does not match InfClass, the function returns INVALID_HANDLE_VALUE and a call to
/// GetLastError returns ERROR_CLASS_MISMATCH.
///
///
/// If multiple INF file styles are specified, the style of the INF file opened can be determined by calling the
/// SetupGetInfInformation function.
///
///
/// Because there may be more than one class GUID with the same class name, callers interested in INF files of a particular class
/// (that is, a particular class GUID) should retrieve the ClassGUID value from the INF file by calling SetupQueryInfVersionInformation.
///
///
/// For legacy INF files, the InfClass string must match the type specified in the OptionType value of the Identification
/// section in the INF file (for example, OptionType=NetAdapter).
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupopeninffilea WINSETUPAPI HINF SetupOpenInfFileA(
// PCSTR FileName, PCSTR InfClass, DWORD InfStyle, PUINT ErrorLine );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupOpenInfFileA")]
public static extern SafeHINF SetupOpenInfFile([MarshalAs(UnmanagedType.LPTStr)] string FileName,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string InfClass, INF_STYLE InfStyle, out uint ErrorLine);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupOpenLog function opens the log files.
///
/// Must be FALSE.
/// TRUE if the log file can be opened. FALSE if an error occurs. To get the error code, call GetLastError.
/// The log files are located in the Windows directory, and the file names are Setupact.log and Setuperr.log.
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupopenlog WINSETUPAPI BOOL SetupOpenLog( BOOL Erase );
[DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupOpenLog")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupOpenLog([MarshalAs(UnmanagedType.Bool)] bool Erase);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupOpenMasterInf function opens the master INF file that contains file and layout information for files shipped
/// with Windows.
///
///
///
/// If SetupOpenMasterInf is successful, it returns a handle to the opened INF file that contains file/layout information for
/// files shipped with Windows. Otherwise, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupopenmasterinf WINSETUPAPI HINF SetupOpenMasterInf();
[DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupOpenMasterInf")]
public static extern HINF SetupOpenMasterInf();
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupPromptForDisk function displays a dialog box that prompts the user for a disk.
///
/// Handle to the parent window for this dialog box.
///
/// Optional pointer to a null-terminated string specifying the dialog title. If this parameter is NULL, the default
/// of ""%s--Files Needed"" (localized) is used. The "%s" is replaced with the text retrieved from the parent window. If no text is
/// retrieved from the parent window, the title is "Files Needed".
///
///
/// Optional pointer to a null-terminated string specifying the name of the disk to insert. If this parameter is NULL,
/// the default "(Unknown)" (localized) is used.
///
///
/// Optional pointer to a null-terminated string specifying the path part of the expected location of the file, for example,
/// F:\x86. If not specified, the path where SetupPromptForDisk most recently located a file is used. If that list is empty,
/// a system default is used.
///
///
/// Pointer to a null-terminated string specifying the name of the file needed (filename part only). The filename is
/// displayed if the user clicks on the Browse button. This routine looks for the file using its compressed form names;
/// therefore, you can pass cmd.exe and not worry that the file actually exists as cmd.ex_ on the source media.
///
///
///
/// Optional pointer to a null-terminated string specifying a tag file (filename part only) that identifies the presence of a
/// particular removable media volume. If the currently selected path would place the file on removable media and a tag file is
/// specified, SetupPromptForDisk looks for the tag file at the root of the drive to determine whether to continue.
///
///
/// For example, if PathToSource is A:\x86, the tagfile is disk1.tag, and the user types B:\x86 into the edit control of the prompt
/// dialog box, the routine looks for B:\disk1.tag to determine whether to continue. If the tag file is not found, the function
/// looks for the tagfile using PathToSource.
///
///
/// If a tag file is not specified, removable media works just like non-removable media and FileSought is looked for before continuing.
///
///
///
/// Specifies the behavior of the dialog box. This parameter can be a combination of the following flags.
/// IDF_CHECKFIRST
/// Check for the file/disk before displaying the prompt dialog box, and, if present, return DPROMPT_SUCCESS immediately.
/// IDF_NOBEEP
/// Prevent the dialog box from beeping to get the user's attention when it first appears.
/// IDF_NOBROWSE
/// Do not display the browse option.
/// IDF_NOCOMPRESSED
/// Do not check for compressed versions of the source file.
/// IDF_NODETAILS
/// Do not display detail information.
/// IDF_NOFOREGROUND
/// Prevent the dialog box from becoming the foreground window.
/// IDF_NOSKIP
/// Do not display the skip option.
/// IDF_OEMDISK
/// Prompt for a disk supplied by a hardware manufacturer.
/// IDF_WARNIFSKIP
/// Warn the user that skipping a file may affect the installation.
///
///
/// Optional pointer to a buffer that, upon return, receives the path (no filename) of the location specified by the user through
/// the dialog box. You should use a null-terminated string. The null-terminated string should not exceed the size of
/// the destination buffer. You can call the function once to get the required buffer size, allocate the necessary memory, and then
/// call the function a second time to retrieve the data. Using this technique, you can avoid errors due to an insufficient buffer
/// size. See the Remarks section.
///
///
/// Size of the buffer pointed to by PathBuffer, in characters. It should be at least MAX_PATH long. This includes the null terminator.
///
///
/// Optional pointer to a variable that receives the required size for PathBuffer, in characters. This includes the null terminator.
///
///
/// The function returns one of the following values.
/// To get extended error information, call GetLastError.
///
///
///
/// If this function is called with a PathBuffer of NULL and a PathBufferSize of zero, the function puts the buffer size
/// needed to hold the specified data into the variable pointed to by PathRequiredSize. If the function succeeds in this, the return
/// value is NO_ERROR. Otherwise, the return value is one of the values described in the Return Values section.
///
///
/// Note
///
/// The setupapi.h header defines SetupPromptForDisk as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setuppromptfordiska WINSETUPAPI UINT SetupPromptForDiskA(
// HWND hwndParent, PCSTR DialogTitle, PCSTR DiskName, PCSTR PathToSource, PCSTR FileSought, PCSTR TagFile, DWORD DiskPromptStyle,
// PSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupPromptForDiskA")]
public static extern uint SetupPromptForDisk(HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPTStr)] string DialogTitle,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string DiskName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string PathToSource,
[MarshalAs(UnmanagedType.LPTStr)] string FileSought, [Optional, MarshalAs(UnmanagedType.LPTStr)] string TagFile, IDF DiskPromptStyle,
[Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder PathBuffer, uint PathBufferSize, out uint PathRequiredSize);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupPromptReboot function asks the user if he wants to reboot the system, optionally dependent on whether any files
/// in a committed file queue were in use during a file operation. If the user answers "yes" to the prompt, shutdown is initiated
/// before this routine returns.
///
///
///
/// Optional pointer to a handle to the file queue upon which to base the decision about whether shutdown is necessary. If FileQueue
/// is not specified, SetupPromptReboot assumes shutdown is necessary and asks the user what to do.
///
/// Handle for the parent window to own windows created by this function.
///
/// Indicates whether or not to prompt the user when SetupPromptReboot is called.
///
/// If TRUE, the user is never asked about rebooting, and system shutdown is not initiated. In this case, FileQueue must be
/// specified. If FALSE, the user is asked about rebooting, as previously described.
///
/// Use ScanOnly to determine if shutdown is necessary separately from actually initiating a shutdown.
///
///
/// The function returns a combination of the following flags or –1 if an error occurs.
/// To get extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setuppromptreboot WINSETUPAPI INT SetupPromptReboot(
// HSPFILEQ FileQueue, HWND Owner, BOOL ScanOnly );
[DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupPromptReboot")]
public static extern int SetupPromptReboot([In, Optional] HSPFILEQ FileQueue, [In, Optional] HWND Owner, [MarshalAs(UnmanagedType.Bool)] bool ScanOnly);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQueryDrivesInDiskSpaceList function fills a buffer with a list of the drives referenced by the file operations
/// listed in the disk-space list.
///
///
/// Handle to the disk-space list.
///
/// Optional pointer to a buffer that receives the drive specifications, such as "X:" or "\server\share". You should use a
/// null-terminated string. The null-terminated string should not exceed the size of the destination buffer. This
/// parameter can be NULL. If this parameter is not specified and no error occurs, the function returns a nonzero value and
/// RequiredSize receives the buffer size required to hold the drive specifications.
///
///
/// Size of the buffer pointed by ReturnBuffer, in characters. This includes the null terminator. This parameter is ignored
/// if ReturnBuffer is not specified.
///
///
/// Optional pointer to a variable that receives the size of the buffer required to hold the null-terminated list of drives,
/// in characters. This includes the null terminator.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
/// If the GetLastError function returns ERROR_INSUFFICIENT_BUFFER, ReturnBuffer was specified, but ReturnBufferSize indicated that
/// the supplied buffer was too small.
///
///
///
/// Note
///
/// The setupapi.h header defines SetupQueryDrivesInDiskSpaceList as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupquerydrivesindiskspacelista WINSETUPAPI BOOL
// SetupQueryDrivesInDiskSpaceListA( HDSKSPC DiskSpace, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueryDrivesInDiskSpaceListA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueryDrivesInDiskSpaceList(HDSKSPC DiskSpace, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder ReturnBuffer,
uint ReturnBufferSize, out uint RequiredSize);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupQueryFileLog function returns information from a setup file log.
///
/// Handle to the file log as returned by SetupInitializeFileLog.
///
/// Optional pointer to the section name for the log file in a format that is meaningful to the caller. You should use a
/// null-terminated string. Required for non-system logs. If no LogSectionName is specified for a system log, a default is supplied.
///
///
/// Name of the file for which log information is desired. You should use a null-terminated string.
///
///
///
/// Indicates what information should be returned to the DataOut buffer. This parameter can be one of the following enumerated values.
///
///
///
/// Value
/// Meaning
///
/// -
/// SetupFileLogSourceFile name
/// Name of the source file as it exists on the source media
///
/// -
/// SetupFileLogChecksum
/// A checksum value used by the system log
///
/// -
/// SetupFileLogDiskTagfile
/// Name of the tag file of the media source containing the source file
///
/// -
/// SetupFileLogDiskDescription
/// The human-readable description of the media where the source file resides
///
/// -
/// SetupFileLogOtherInfo
/// Additional information associated with the logged file
///
///
///
/// If the value of DesiredInfo is greater than SetupFileLogOtherInfo the function will fail, and GetLastError will return ERROR_INVALID_PARAMETER.
///
///
///
/// Optional pointer to a buffer in which this function returns the requested information for the file. You should use a
/// null-terminated string. The null-terminated string should not exceed the size of the destination buffer. You can
/// call the function once to get the required buffer size, allocate the necessary memory, and then call the function a second time
/// to retrieve the data. See the Remarks section. Using this technique, you can avoid errors due to an insufficient buffer size.
/// Not all information is provided for every file. An error is not returned if an empty entry for the file exists in the log. This
/// parameter can be NULL.
///
///
/// Size of the DataOut buffer, in characters. This includes the null terminator. If the buffer is too small and DataOut is
/// specified, data is not stored in the buffer and the function returns zero. If DataOut is not specified, the ReturnBufferSize
/// parameter is ignored.
///
///
/// Optional pointer to a variable that receives the required size of DataOut, in characters. This number includes the null terminator.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// If this function is called with a DataOut of NULL and a ReturnBufferSize of zero, the function puts the buffer size
/// needed to hold the specified data into the variable pointed to by RequiredSize. If the function succeeds in this, the return
/// value is a nonzero value. Otherwise, the return value is zero and extended error information can be obtained by calling GetLastError.
///
///
/// If the value of DesiredInfo is greater than SetupFileLogOtherInfo the function will fail, and GetLastError will return ERROR_INVALID_PARAMETER.
///
///
/// Note
///
/// The setupapi.h header defines SetupQueryFileLog as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueryfileloga WINSETUPAPI BOOL SetupQueryFileLogA(
// HSPFILELOG FileLogHandle, PCSTR LogSectionName, PCSTR TargetFilename, SetupFileLogInfo DesiredInfo, PSTR DataOut, DWORD
// ReturnBufferSize, PDWORD RequiredSize );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueryFileLogA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueryFileLog(HSPFILELOG FileLogHandle, [Optional, MarshalAs(UnmanagedType.LPTStr)] string LogSectionName,
[MarshalAs(UnmanagedType.LPTStr)] string TargetFilename, SetupFileLogInfo DesiredInfo, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder DataOut,
uint ReturnBufferSize, out uint RequiredSize);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupQueryInfFileInformation function returns an INF filename from an SP_INF_INFORMATION structure to a buffer.
///
///
/// Pointer to an SP_INF_INFORMATION structure returned from a call to the SetupGetInfInformation function.
///
///
/// Index of the constituent INF filename to retrieve. This index can be in the range [0, InfInformation.InfCount). Meaning that the
/// values zero through, but not including, InfInformation.InfCount are valid.
///
///
/// If not NULL, ReturnBuffer is a pointer to a buffer in which this function returns the full INF filename. You should use a
/// null-terminated string. The null-terminated string should not exceed the size of the destination buffer. You can
/// call the function once to get the required buffer size, allocate the necessary memory, and then call the function a second time
/// to retrieve the data. See the Remarks section. Using this technique, you can avoid errors due to an insufficient buffer size.
/// This parameter can be NULL.
///
///
/// Size of the buffer pointed to by the ReturnBuffer parameter, in characters. This includes the null terminator.
///
///
/// If not NULL, pointer to a variable that receives the required size for the ReturnBuffer buffer, in characters. This
/// includes the null terminator. If ReturnBuffer is specified and the actual size is larger than ReturnBufferSize, the
/// function fails and a call to GetLastError returns ERROR_INSUFFICIENT_BUFFER.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// If this function is called with a ReturnBuffer of NULL and a ReturnBufferSize of zero, the function puts the buffer size
/// needed to hold the specified data into the variable pointed to by RequiredSize. If the function succeeds in this, the return
/// value is a nonzero value. Otherwise, the return value is zero and extended error information can be obtained by calling GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupQueryInfFileInformation as an alias which automatically selects the ANSI or Unicode version
/// of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with
/// code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueryinffileinformationa WINSETUPAPI BOOL
// SetupQueryInfFileInformationA( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PSTR ReturnBuffer, DWORD ReturnBufferSize,
// PDWORD RequiredSize );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueryInfFileInformationA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueryInfFileInformation(in SP_INF_INFORMATION InfInformation, uint InfIndex,
[Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder ReturnBuffer, uint ReturnBufferSize, out uint RequiredSize);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupQueryInfOriginalFileInformation function returns the original name of an OEM INF file.
///
///
/// Pointer to an SP_INF_INFORMATION structure returned from a call to the SetupGetInfInformation function.
///
///
/// Index of the constituent INF file name to retrieve. This index can be in the range [0, InfInformation.InfCount). Meaning that
/// the values zero through, but not including, InfInformation.InfCount are valid.
///
///
/// Optional pointer to an SP_ALTPLATFORM_INFO_V1 or SP_ALTPLATFORM_INFO_V2 structure used to pass information for an alternate
/// platform to SetupQueryInfOriginalFileInformation.
///
///
/// Pointer to an SP_ORIGINAL_FILE_INFO structure that receives the original INF file name and catalog file information returned by SetupQueryInfOriginalFileInformation.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupQueryInfOriginalFileInformation as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueryinforiginalfileinformationa WINSETUPAPI BOOL
// SetupQueryInfOriginalFileInformationA( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PSP_ALTPLATFORM_INFO
// AlternatePlatformInfo, PSP_ORIGINAL_FILE_INFO_A OriginalFileInfo );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueryInfOriginalFileInformationA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueryInfOriginalFileInformation(in SP_INF_INFORMATION InfInformation, uint InfIndex,
in SP_ALTPLATFORM_INFO AlternatePlatformInfo, out SP_ORIGINAL_FILE_INFO OriginalFileInfo);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupQueryInfOriginalFileInformation function returns the original name of an OEM INF file.
///
///
/// Pointer to an SP_INF_INFORMATION structure returned from a call to the SetupGetInfInformation function.
///
///
/// Index of the constituent INF file name to retrieve. This index can be in the range [0, InfInformation.InfCount). Meaning that
/// the values zero through, but not including, InfInformation.InfCount are valid.
///
///
/// Optional pointer to an SP_ALTPLATFORM_INFO_V1 or SP_ALTPLATFORM_INFO_V2 structure used to pass information for an alternate
/// platform to SetupQueryInfOriginalFileInformation.
///
///
/// Pointer to an SP_ORIGINAL_FILE_INFO structure that receives the original INF file name and catalog file information returned by SetupQueryInfOriginalFileInformation.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupQueryInfOriginalFileInformation as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueryinforiginalfileinformationa WINSETUPAPI BOOL
// SetupQueryInfOriginalFileInformationA( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PSP_ALTPLATFORM_INFO
// AlternatePlatformInfo, PSP_ORIGINAL_FILE_INFO_A OriginalFileInfo );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueryInfOriginalFileInformationA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueryInfOriginalFileInformation(in SP_INF_INFORMATION InfInformation, uint InfIndex,
[In, Optional] IntPtr AlternatePlatformInfo, out SP_ORIGINAL_FILE_INFO OriginalFileInfo);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQueryInfVersionInformation function returns INF file version information from an SP_INF_INFORMATION structure to
/// a buffer.
///
///
///
/// Pointer to an SP_INF_INFORMATION structure previously returned from a call to the SetupGetInfInformation function.
///
///
/// Index of the constituent INF file to retrieve version information from. This index can be in the range [0,
/// InfInformation.InfCount). Meaning that the values zero through, but not including, InfInformation.InfCount are valid.
///
///
/// Optional pointer to a null-terminated string containing the key name whose associated string is to be retrieved. If this
/// parameter is NULL, all resource keys are copied to the supplied buffer. Each string is null-terminated, with an
/// extra null at the end of the list.
///
///
/// If not NULL, ReturnBuffer points to a call-supplied character buffer in which this function returns the INF file style.
/// You should use a null-terminated string. The null-terminated string should not exceed the size of the destination
/// buffer. You can call the function once to get the required buffer size, allocate the necessary memory, and then call the
/// function a second time to retrieve the data. Using this technique, you can avoid errors due to an insufficient buffer size. See
/// the Remarks section. This parameter can be NULL.
///
///
/// Size of the buffer pointed to by the ReturnBuffer parameter, in characters. This number includes the null terminator.
///
///
/// If not NULL, pointer to a variable that receives the size required for the buffer pointed to by the ReturnBuffer
/// parameter, in characters. This number includes the null terminator. If ReturnBuffer is specified and the actual size is
/// larger than the value specified by ReturnBufferSize, the function fails and a call to GetLastError returns ERROR_INSUFFICIENT_BUFFER.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// If this function is called with a ReturnBuffer of NULL and a ReturnBufferSize of zero, the function puts the buffer size
/// needed to hold the specified data into the variable pointed to by RequiredSize. If the function succeeds in this, the return
/// value is a nonzero value. Otherwise, the return value is zero and extended error information can be obtained by calling GetLastError.
///
///
/// If SetupQueryInfVersionInformation is called on a legacy INF file , then version information is generated from the legacy
/// INF file in the following manner:
///
///
/// -
/// The OptionType key in the Identification section of the legacy file is returned as the Class key value.
///
/// -
/// The FileType key in the Signature section of the legacy INF file becomes the Signature key value.
///
/// -
/// If the value of the FileType key of the legacy INF file is MICROSOFT_FILE, then the Provider key value is set to "Microsoft".
///
///
/// The following table summarizes how the information is translated before it is passed into the SP_INF_INFORMATION structure.
///
///
/// Legacy file information
/// Windows INF information
///
/// -
///
///
///
/// -
///
///
///
/// -
/// (if the FileType is MICROSOFT_FILE)
///
///
///
///
/// Note
///
/// The setupapi.h header defines SetupQueryInfVersionInformation as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueryinfversioninformationa WINSETUPAPI BOOL
// SetupQueryInfVersionInformationA( PSP_INF_INFORMATION InfInformation, UINT InfIndex, PCSTR Key, PSTR ReturnBuffer, DWORD
// ReturnBufferSize, PDWORD RequiredSize );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueryInfVersionInformationA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueryInfVersionInformation(in SP_INF_INFORMATION InfInformation, uint InfIndex,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string Key, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder ReturnBuffer,
uint ReturnBufferSize, out uint RequiredSize);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQuerySourceList function queries the current list of installation sources. The list is built from the system and
/// user-specific lists, and potentially overridden by a temporary list (see SetupSetSourceList).
///
///
///
/// Specifies which list to query. This parameter can be any combination of the following values.
/// SRCLIST_SYSTEM
/// Query the system list.
/// SRCLIST_USER
/// Query the per-user list.
///
/// Note If the system and the user lists are both retrieved, they are merged with those items in the system list that appear first.
///
/// Note If none of the preceding flags are specified, the entire current (merged) list is returned.
/// SRCLIST_NOSTRIPPLATFORM
///
/// 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.
///
///
///
/// Pointer to a variable in which this function returns a pointer to an array of sources. Use a null-terminated string. The caller
/// must free this array with a call to SetupFreeSourceList.
///
/// Pointer to a variable in which this function returns the number of sources in the list.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupQuerySourceList as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupquerysourcelista WINSETUPAPI BOOL
// SetupQuerySourceListA( DWORD Flags, PCSTR **List, PUINT Count );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQuerySourceListA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQuerySourceList(SRCLIST Flags, out IntPtr List, out uint Count);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQuerySourceList function queries the current list of installation sources. The list is built from the system and
/// user-specific lists, and potentially overridden by a temporary list (see SetupSetSourceList).
///
///
///
/// Specifies which list to query. This parameter can be any combination of the following values.
/// SRCLIST_SYSTEM
/// Query the system list.
/// SRCLIST_USER
/// Query the per-user list.
///
/// Note If the system and the user lists are both retrieved, they are merged with those items in the system list that appear first.
///
/// Note If none of the preceding flags are specified, the entire current (merged) list is returned.
/// SRCLIST_NOSTRIPPLATFORM
///
/// 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.
///
///
/// Returns a pointer to an array of sources.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupquerysourcelista WINSETUPAPI BOOL
// SetupQuerySourceListA( DWORD Flags, PCSTR **List, PUINT Count );
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQuerySourceListA")]
public static bool SetupQuerySourceList(SRCLIST Flags, out string[] List)
{
List = new string[0];
if (!SetupQuerySourceList(Flags, out var list, out var count))
return false;
try
{
List = list.ToStringEnum((int)count).ToArray();
return true;
}
finally
{
SetupFreeSourceList(list, count);
}
}
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQuerySpaceRequiredOnDrive function examines a disk space list to determine the space that is required to perform
/// all the file operations listed for a specific drive.
///
///
/// The handle to a disk space list.
///
/// A pointer to a null-terminated string that specifies the drive where space information is to be returned.
/// This should be in the form "x:" or "\server\share".
///
///
///
/// If the function succeeds, this parameter receives the amount of additional space that is required to process all the file
/// operations listed in the disk space list for the drive that DriveSpec specifies.
///
///
/// The SetupQuerySpaceRequiredOnDrive function calculates the additional space required on the target drive by checking for
/// preexisting versions of the files on the target drive.
///
///
/// For example, if a file operation copies a 2000-byte file, FIRST.EXE, to the directory, C:\MYPROG, the
/// SetupQuerySpaceRequiredOnDrive function automatically checks for a preexisting version of that file in that directory. If
/// a preexisting version of C:\MYPROG\FIRST.EXE has a file size of 500 bytes, the additional space required on the drive C for that
/// operation is 1500 bytes.
///
///
/// The value received can be 0 (zero) or a negative number, if additional space is not required, or if space is freed on the target drive.
///
///
/// If FIRST.EXE in the preceding example is being deleted from the drive C, the amount of space required is 2000 bytes, or the
/// space freed on drive C.
///
///
/// If the preexisting version has a file size of 5000 bytes, then the disk space required to replace it with the 2000-byte
/// FIRST.EXE is 3000 bytes.
///
/// File sizes are rounded to disk cluster boundaries.
///
/// Reserved; must be 0 (zero).
/// Reserved; must be 0 (zero).
///
///
/// If the function succeeds, the return value is a nonzero value and SpaceRequired receives the amount of space required by the
/// file operations listed in the current disk space list.
///
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_DRIVE
/// The specified drive is not on the disk-space list.
///
/// -
/// ERROR_INVALID_HANDLE
/// The specified DiskSpace handle is invalid.
///
/// -
/// ERROR_INVALID_PARAMETER
/// The specified DriveSpec string is invalid.
///
///
///
///
/// Note
///
/// The setupapi.h header defines SetupQuerySpaceRequiredOnDrive as an alias which automatically selects the ANSI or Unicode version
/// of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with
/// code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueryspacerequiredondrivea WINSETUPAPI BOOL
// SetupQuerySpaceRequiredOnDriveA( HDSKSPC DiskSpace, PCSTR DriveSpec, LONGLONG *SpaceRequired, PVOID Reserved1, UINT Reserved2 );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQuerySpaceRequiredOnDriveA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQuerySpaceRequiredOnDrive(HDSKSPC DiskSpace, [MarshalAs(UnmanagedType.LPTStr)] string DriveSpec,
out long SpaceRequired, [In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupQueueCopy function adds a single file copy operation to a setup file queue.
///
/// Handle to a setup file queue, as returned by SetupOpenFileQueue.
///
/// Pointer to a null-terminated string that specifies the root of the source for this copy, such as A:.
///
///
/// Pointer to a null-terminated string that specifies the path relative to SourceRootPath where the file can be found. This
/// parameter may be NULL.
///
///
/// Pointer to a null-terminated string that specifies the file name part of the file to be copied.
///
///
/// Pointer to a null-terminated string that specifies a description of the source media to be used during disk prompts. This
/// parameter can be NULL.
///
///
/// Pointer to a null-terminated string that specifies a tag file whose presence at SourceRootPath indicates the presence of
/// the source media. This parameter may be NULL. If not specified, the file itself will be used as the tag file if required.
///
///
/// Pointer to a null-terminated string that specifies the directory where the file is to be copied.
///
///
/// Pointer to a null-terminated string that specifies the name of the target file. This parameter may be NULL. If not
/// specified, the target file will have the same name as the source file.
///
///
/// Specifies the behavior of the file copy operation. This parameter may be a combination of the following values.
/// SP_COPY_DELETESOURCE
/// Delete the source file upon successful copy. The caller is not notified if the delete 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 filename part of DestinationName, if specified, is stripped and replaced with the filename 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.)
///
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// If a UNC directory is specified as the target directory of a file copy operation, you must ensure it exists before the queue is
/// committed. The setup functions do not check for the existence of and do not create UNC directories. If the target UNC directory
/// does not exist, the file copy will fail.
///
///
/// Note
///
/// The setupapi.h header defines SetupQueueCopy as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueuecopya WINSETUPAPI BOOL SetupQueueCopyA(
// HSPFILEQ QueueHandle, PCSTR SourceRootPath, PCSTR SourcePath, PCSTR SourceFilename, PCSTR SourceDescription, PCSTR SourceTagfile,
// PCSTR TargetDirectory, PCSTR TargetFilename, DWORD CopyStyle );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueueCopyA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueueCopy(HSPFILEQ QueueHandle, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceRootPath,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string SourcePath, [MarshalAs(UnmanagedType.LPTStr)] string SourceFilename,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceDescription, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceTagfile,
[MarshalAs(UnmanagedType.LPTStr)] string TargetDirectory, [Optional, MarshalAs(UnmanagedType.LPTStr)] string TargetFilename, SP_COPY CopyStyle);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQueueCopyIndirect function is an extended form of SetupQueueCopy passing additional parameters as a structure
/// (SP_FILE_COPY_PARAMS). Other than this, the behavior is identical.
///
///
/// Pointer to a SP_FILE_COPY_PARAMS structure that describes the file copy operation.
///
/// If the function succeeds, the return value is an nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// If a UNC directory is specified as the target directory of a file copy operation, you must ensure it exists before the queue is
/// committed. The setup functions do not check for the existence of and do not create UNC directories. If the target UNC directory
/// does not exist, the file copy will fail.
///
///
/// Note
///
/// The setupapi.h header defines SetupQueueCopyIndirect as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueuecopyindirecta WINSETUPAPI BOOL
// SetupQueueCopyIndirectA( PSP_FILE_COPY_PARAMS_A CopyParams );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueueCopyIndirectA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueueCopyIndirect(in SP_FILE_COPY_PARAMS CopyParams);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQueueCopySection function places all the files in a section of an INF file in a setup queue for copying. The
/// section must be in the correct Copy Files format and the INF file must contain SourceDisksFiles and
/// SourceDisksNames sections (or have had the INF files containing those sections appended).
///
///
/// Handle to a setup file queue, as returned by SetupOpenFileQueue.
///
/// Pointer to a null-terminated string that specifies the root of the source for this copy, such as A:.
///
///
/// Handle to an open INF file that contains the SourceDisksFiles and SourceDisksNames sections. If ListInfHandle is
/// not specified, InfHandle contains the section names. If platform-specific sections exist for the user's system (for example,
/// SourceDisksNames.x86 and SourceDisksFiles.x86), the platform-specific section will be used.
///
///
/// Optional handle to an open INF file that contains the section to queue for copying. If ListInfHandle is not specified, InfHandle
/// is assumed to contain the section.
///
/// Pointer to a null-terminated string that specifies the name of the section to be queued for copy.
///
/// Flags that control the behavior of the file copy operation. These flags may be a combination of the following values.
/// SP_COPY_DELETESOURCE
/// Delete the source file upon successful copy. The caller is not notified if the delete fails.
/// SP_COPY_REPLACEONLY
/// Copy the file only if doing so would overwrite a file at the destination path.
/// SP_COPY_NEWER_OR_SAME
///
/// Examine each file being copied to see if its version resources indicate that it is either equal in 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:\x86s\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 filename part of DestinationName, if specified, is stripped and replaced with the filename 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.)
///
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// If a UNC directory is specified as the target directory of a file copy operation, you must ensure it exists before the queue is
/// committed. The setup functions do not check for the existence of and do not create UNC directories. If the target UNC directory
/// does not exist, the file copy will fail.
///
/// This function requires a Windows INF file. Some older INF file formats may not be supported.
///
/// Note
///
/// The setupapi.h header defines SetupQueueCopySection as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueuecopysectiona WINSETUPAPI BOOL
// SetupQueueCopySectionA( HSPFILEQ QueueHandle, PCSTR SourceRootPath, HINF InfHandle, HINF ListInfHandle, PCSTR Section, DWORD
// CopyStyle );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueueCopySectionA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueueCopySection(HSPFILEQ QueueHandle, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceRootPath,
HINF InfHandle, [In, Optional] HINF ListInfHandle, [MarshalAs(UnmanagedType.LPTStr)] string Section, SP_COPY CopyStyle);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQueueDefaultCopy function adds a single file to a setup file queue for copying, using the default source media
/// and destination as specified in an INF file.
///
///
/// Handle to a setup file queue, as returned by SetupOpenFileQueue.
///
/// Handle to an open INF file that contains the SourceDisksFiles and SourceDisksNames sections. If platform-specific
/// sections exist for the user's system (for example, SourceDisksNames.x86 and SourceDisksFiles.x86), the
/// platform-specific section will be used.
///
///
/// Pointer to a null-terminated string that specifies the root directory of the source for this copy such as A:.
///
/// Pointer to a null-terminated string that specifies the file name of the file to be copied.
/// Pointer to a null-terminated string that specifies the file name of the target file.
///
/// Flags that control the behavior of the file copy operation. These flags may be a combination of the following values.
/// SP_COPY_DELETESOURCE
/// Delete the source file upon successful copy. The caller is not notified if the delete fails.
/// SP_COPY_REPLACEONLY
/// Copy the file only if doing so would overwrite a file at the destination path.
/// SP_COPY_NEWER_OR_SAME
///
/// Examine each file being copied to see if its version resources indicate that it is either equal in 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 filename part of DestinationName, if specified, is stripped and replaced with the filename 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.)
///
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// If a UNC directory is specified as the target directory of a file copy operation, you must ensure it exists before the queue is
/// committed. The setup functions do not check for the existence of and do not create UNC directories. If the target UNC directory
/// does not exist, the file copy will fail.
///
///
/// The default destination used by this function is specified by the DefaultDestDir key in the DestinationDirs
/// section of an INF file.
///
/// This function requires a Windows INF file. Some older INF file formats may not be supported.
///
/// Note
///
/// The setupapi.h header defines SetupQueueDefaultCopy as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueuedefaultcopya WINSETUPAPI BOOL
// SetupQueueDefaultCopyA( HSPFILEQ QueueHandle, HINF InfHandle, PCSTR SourceRootPath, PCSTR SourceFilename, PCSTR TargetFilename,
// DWORD CopyStyle );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueueDefaultCopyA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueueDefaultCopy(HSPFILEQ QueueHandle, HINF InfHandle, [Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceRootPath,
[MarshalAs(UnmanagedType.LPTStr)] string SourceFilename, [Optional, MarshalAs(UnmanagedType.LPTStr)] string TargetFilename, SP_COPY CopyStyle);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupQueueDelete function places an individual file delete operation on a setup file queue.
///
/// Handle to a setup file queue, as returned by SetupOpenFileQueue.
///
/// Pointer to a null-terminated string that specifies the first part of the path of the file to be deleted. If PathPart2 is
/// NULL, PathPart1 is the full path of the file to be deleted.
///
///
/// Pointer to a null-terminated string that specifies the second part of the path of the file to be deleted. This parameter
/// may be NULL. This is appended to PathPart1 to form the full path of the file to be deleted. The function checks for and
/// collapses duplicated path separators when it combines PathPart1 and PathPart2.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Because delete operations are assumed to take place on fixed media, the user will not be prompted when the queue is committed.
///
/// Note
///
/// The setupapi.h header defines SetupQueueDelete as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueuedeletea WINSETUPAPI BOOL SetupQueueDeleteA(
// HSPFILEQ QueueHandle, PCSTR PathPart1, PCSTR PathPart2 );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueueDeleteA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueueDelete(HSPFILEQ QueueHandle, [MarshalAs(UnmanagedType.LPTStr)] string PathPart1,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string PathPart2);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQueueDeleteSection function queues all the files in a section of an INF file for deletion. The section must be
/// in the correct Delete Files format and the INF file must contain a DestinationDirs section.
///
///
/// Handle to a setup file queue, as returned by SetupOpenFileQueue.
///
/// Handle to an open INF file that contains the DestinationDirs section. If ListInfHandle is not specified, InfHandle
/// contains the section name.
///
///
/// Optional handle to an open INF file that contains the section to queue for deletion. If ListInfHandle is not specified,
/// InfHandle is assumed to contain the section name.
///
/// Pointer to a null-terminated string that specifies the name of the section to be queued for deletion.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// This function requires a Windows INF file. Some older INF file formats may not be supported.
///
/// Note
///
/// The setupapi.h header defines SetupQueueDeleteSection as an alias which automatically selects the ANSI or Unicode version of
/// this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code
/// that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueuedeletesectiona WINSETUPAPI BOOL
// SetupQueueDeleteSectionA( HSPFILEQ QueueHandle, HINF InfHandle, HINF ListInfHandle, PCSTR Section );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueueDeleteSectionA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueueDeleteSection(HSPFILEQ QueueHandle, HINF InfHandle, [In, Optional] HINF ListInfHandle,
[MarshalAs(UnmanagedType.LPTStr)] string Section);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupQueueRename function places an individual file rename operation on a setup file queue.
///
/// Handle to a setup file queue, as returned by SetupOpenFileQueue.
///
/// Pointer to a null-terminated string that specifies the source path of the file to be renamed. If SourceFileName is not
/// specified, SourcePath is assumed to be the full path.
///
///
/// Pointer to a null-terminated string that specifies the file name part of the file to be renamed. If not specified, SourcePath is
/// the full path.
///
///
/// Pointer to a null-terminated string that specifies the target directory. When this parameter is specified, the rename operation
/// is actually a move operation. If TargetPath is not specified, the file is renamed but remains in its current location.
///
/// Pointer to a null-terminated string that specifies the new name for the source file.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Because rename operations are assumed to take place on fixed media, the user will not be prompted when the queue is committed.
///
/// Note
///
/// The setupapi.h header defines SetupQueueRename as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueuerenamea WINSETUPAPI BOOL SetupQueueRenameA(
// HSPFILEQ QueueHandle, PCSTR SourcePath, PCSTR SourceFilename, PCSTR TargetPath, PCSTR TargetFilename );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueueRenameA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueueRename(HSPFILEQ QueueHandle, [MarshalAs(UnmanagedType.LPTStr)] string SourcePath,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string SourceFilename, [Optional, MarshalAs(UnmanagedType.LPTStr)] string TargetPath,
[MarshalAs(UnmanagedType.LPTStr)] string TargetFilename);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupQueueRenameSection function queues a section in an INF file for renaming. The section must be in the correct
/// rename list section format and the INF file must contain a DestinationDirs section.
///
///
/// Handle to a setup file queue, as returned by SetupOpenFileQueue.
///
/// Handle to the INF file that contains the DestinationDirs section. If ListInfHandle is not specified, InfHandle contains
/// the section name.
///
///
/// Optional handle to an INF file that contains the section to queue for renaming. If ListInfHandle is not specified, InfHandle is
/// assumed to contain the section name.
///
/// Name of the section to be queued for renaming.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// You cannot queue file moves with SetupQueueRenameSection because the form of a rename list section limits section
/// renaming to within the same directory.
///
/// This function requires a Windows INF file. Some older INF file formats may not be supported.
///
/// Note
///
/// The setupapi.h header defines SetupQueueRenameSection as an alias which automatically selects the ANSI or Unicode version of
/// this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code
/// that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupqueuerenamesectiona WINSETUPAPI BOOL
// SetupQueueRenameSectionA( HSPFILEQ QueueHandle, HINF InfHandle, HINF ListInfHandle, PCSTR Section );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupQueueRenameSectionA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupQueueRenameSection(HSPFILEQ QueueHandle, HINF InfHandle, [In, Optional] HINF ListInfHandle,
[MarshalAs(UnmanagedType.LPTStr)] string Section);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupRemoveFileLogEntry function removes an entry or section from a file log.
///
///
/// Handle to the file log as returned by SetupInitializeFileLog. The caller must not have passed SPFILELOG_QUERYONLY when the log
/// file was initialized.
///
///
/// Pointer to a null-terminated string that specifies the name for a logical grouping of names within the log file. Required
/// for non-system logs. Otherwise, LogSectionName may be NULL.
///
///
/// Pointer to a null-terminated string that specifies the name of the file as it exists on the target. This name should be
/// in whatever format is meaningful to the caller. If NULL, the section specified by LogSectionName is removed. The main
/// section cannot be removed.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupRemoveFileLogEntry as an alias which automatically selects the ANSI or Unicode version of
/// this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code
/// that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupremovefilelogentrya WINSETUPAPI BOOL
// SetupRemoveFileLogEntryA( HSPFILELOG FileLogHandle, PCSTR LogSectionName, PCSTR TargetFilename );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupRemoveFileLogEntryA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupRemoveFileLogEntry(HSPFILELOG FileLogHandle, [Optional, MarshalAs(UnmanagedType.LPTStr)] string LogSectionName,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string TargetFilename);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupRemoveFromDiskSpaceList function removes a file delete or copy operation from a disk-space list.
///
/// Handle to a disk-space list.
///
/// Pointer to a null-terminated string that specifies the file name of the file to remove from the disk-space list. This is
/// typically a fully qualified path. Otherwise, the path must be relative to the current directory.
///
///
/// File operation to be removed from the list. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// FILEOP_DELETE
/// A file delete operation.
///
/// -
/// FILEOP_COPY
/// A file copy operation.
///
///
///
/// Must be zero.
/// Must be zero.
///
///
/// If the file was not in the list, the SetupRemoveFromDiskSpaceList function returns a nonzero value and GetLastError
/// returns ERROR_INVALID_DRIVE or ERROR_INVALID_NAME. If the file was in the list then upon success the routine returns a nonzero
/// value and GetLastError returns NO_ERROR.
///
/// If the routine fails for some other reason, it returns zero and GetLastError returns extended error information.
///
///
/// Note
///
/// The setupapi.h header defines SetupRemoveFromDiskSpaceList as an alias which automatically selects the ANSI or Unicode version
/// of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with
/// code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupremovefromdiskspacelista WINSETUPAPI BOOL
// SetupRemoveFromDiskSpaceListA( HDSKSPC DiskSpace, PCSTR TargetFilespec, UINT Operation, PVOID Reserved1, UINT Reserved2 );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupRemoveFromDiskSpaceListA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupRemoveFromDiskSpaceList(HDSKSPC DiskSpace, [MarshalAs(UnmanagedType.LPTStr)] string TargetFilespec,
FILEOP Operation, [In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupRemoveFromSourceList function removes a value from the list of installation sources for either the current user
/// or the system. The system and user lists are merged at run time.
///
/// A caller of this function is required have administrative privileges, otherwise the function fails.
///
///
/// Specifies which source to remove from the list. This parameter can be any combination of the following values.
/// SRCLIST_SYSTEM
/// Remove the source to the per-system list. The caller must be an administrator.
/// SRCLIST_USER
/// Remove the source to the per-user list.
/// SRCLIST_SYSIFADMIN
///
/// If the caller is an administrator, the source is removed from the per-system list; if the caller is not an administrator, the
/// source is removed from 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
/// removed from the temporary list.
///
/// SRCLIST_SUBDIRS
/// Remove all subdirectories of the source.
///
/// Pointer to a null-terminated string that specifies the source to remove from the list.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupRemoveFromSourceList as an alias which automatically selects the ANSI or Unicode version of
/// this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code
/// that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupremovefromsourcelista WINSETUPAPI BOOL
// SetupRemoveFromSourceListA( DWORD Flags, PCSTR Source );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupRemoveFromSourceListA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupRemoveFromSourceList(SRCLIST Flags, [MarshalAs(UnmanagedType.LPTStr)] string Source);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupRemoveInstallSectionFromDiskSpaceList function searches an Install section of an INF file for
/// CopyFiles and DelFiles lines, and removes the file operations specified in those sections from a disk-space list.
///
///
/// Handle to a disk-space list.
///
/// Handle to an open INF file that contains the Install section. If LayoutInfHandle is not specified, the INF file must also
/// contain the section specified by SectionName.
///
///
/// Optional handle to the INF file that contains the SourceDisksFiles sections. Otherwise, that section is assumed to exist
/// in the INF file specified by InfHandle.
///
///
/// Pointer to a null-terminated string that specifies the name of the section to be added to the disk-space list.
///
/// Must be zero.
/// Must be zero.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// This function requires a Windows INF file. Some older INF file formats may not be supported.
///
/// Note
///
/// The setupapi.h header defines SetupRemoveInstallSectionFromDiskSpaceList as an alias which automatically selects the ANSI or
/// Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the
/// encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors.
/// For more information, see Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupremoveinstallsectionfromdiskspacelista WINSETUPAPI
// BOOL SetupRemoveInstallSectionFromDiskSpaceListA( HDSKSPC DiskSpace, HINF InfHandle, HINF LayoutInfHandle, PCSTR SectionName,
// PVOID Reserved1, UINT Reserved2 );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupRemoveInstallSectionFromDiskSpaceListA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupRemoveInstallSectionFromDiskSpaceList(HDSKSPC DiskSpace, HINF InfHandle, [In, Optional] HINF LayoutInfHandle,
[MarshalAs(UnmanagedType.LPTStr)] string SectionName, [In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupRemoveSectionFromDiskSpaceList function removes the file delete or copy operations listed in a Copy Files
/// section of an INF file from a disk-space list.
///
///
/// Handle to the disk-space list.
///
/// Handle to an open INF file that contains the SourceDisksFiles section. If ListInfHandle is not specified, this INF file
/// must also contain the section specified by SectionName.
///
///
/// Optional handle to an open INF file that contains the section to remove from the disk-space list. Otherwise, InfHandle must
/// contain the section specified by SectionName.
///
///
/// Pointer to a null-terminated string that specifies the name of the Copy Files or Delete Files section to remove
/// from the disk-space list.
///
///
/// File operation to remove from the list. This parameter can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// FILEOP_DELETE
/// A file delete operation.
///
/// -
/// FILEOP_COPY
/// A file copy operation.
///
///
///
/// Must be zero.
/// Must be zero.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
///
/// The file operations removed by the SetupRemoveSectionFromDiskSpaceList function are typically those that have been added
/// to the list by using the SetupAddSectionToDiskSpaceList function, though this is not a requirement. The
/// SetupRemoveSectionFromDiskSpaceList function ignores files in the INF section that are not listed in the disk-space list.
///
/// This function requires a Windows INF file. Some older INF file formats may not be supported.
///
/// Note
///
/// The setupapi.h header defines SetupRemoveSectionFromDiskSpaceList as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupremovesectionfromdiskspacelista WINSETUPAPI BOOL
// SetupRemoveSectionFromDiskSpaceListA( HDSKSPC DiskSpace, HINF InfHandle, HINF ListInfHandle, PCSTR SectionName, UINT Operation,
// PVOID Reserved1, UINT Reserved2 );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupRemoveSectionFromDiskSpaceListA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupRemoveSectionFromDiskSpaceList(HDSKSPC DiskSpace, HINF InfHandle, [In, Optional] HINF ListInfHandle,
[MarshalAs(UnmanagedType.LPTStr)] string SectionName, FILEOP Operation, [In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The RenameError function generates a dialog box that informs the user of a file renaming error.
///
/// Handle to the parent window for this dialog box.
///
/// Pointer to a null-terminated string that specifies the error dialog box title. This parameter may be NULL. If this
/// parameter is NULL, the default title of "Rename Error" (localized) is used.
///
///
/// Pointer to a null-terminated string that specifies the full path of the source file on which the operation failed.
///
///
/// Pointer to a null-terminated string that specifies the full path of the target file on which the operation failed.
///
/// The system error code encountered during the file operation.
///
/// Specifies display formatting and behavior of the dialog box. This parameter can be one of the following flags.
/// IDF_NOBEEP
/// Prevent the dialog box from beeping when it first appears.
/// IDF_NOFOREGROUND
/// Prevent the dialog box from becoming the foreground window.
///
///
/// This function returns one of the following values.
/// To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupRenameError as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setuprenameerrora WINSETUPAPI UINT SetupRenameErrorA(
// HWND hwndParent, PCSTR DialogTitle, PCSTR SourceFile, PCSTR TargetFile, UINT Win32ErrorCode, DWORD Style );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupRenameErrorA")]
public static extern uint SetupRenameError(HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPTStr)] string DialogTitle,
[MarshalAs(UnmanagedType.LPTStr)] string SourceFile, [MarshalAs(UnmanagedType.LPTStr)] string TargetFile, Win32Error Win32ErrorCode, IDF Style);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupScanFileQueue function scans a setup file queue, performing an operation on each node in its copy list. The
/// operation is specified by a set of flags. This function can be called either before or after the queue has been committed.
///
///
/// Handle to the setup file queue whose copy list is to be scanned or iterated.
///
///
/// Flags to combine to control the file queue scan operation. Note that either SPQ_SCAN_FILE_PRESENCE, SPQ_SCAN_USE_CALLBACK,
/// SPQ_SCAN_USE_CALLBACKEX, or SPQ_SCAN_FILE_VALIDITY must be specified.
///
///
///
/// Flag
/// Meaning
///
/// -
/// SPQ_SCAN_FILE_PRESENCE
/// Target files in the copy queue are already present on the target.
///
/// -
/// SPQ_SCAN_FILE_VALIDITY
///
/// Target files in the copy queue are already present on the target with valid signatures. Available with Windows 2000 and later versions.
///
///
/// -
/// SPQ_SCAN_USE_CALLBACK
///
/// Callback routine for each node of the queue. If the callback routine returns a nonzero value, the queue processing stops and
/// SetupScanFileQueue returns zero. Issue a SPFILENOTIFY_QUEUESCAN notification code and a pass a pointer to the target path as Param1.
///
///
/// -
/// SPQ_SCAN_USE_CALLBACKEX
///
/// Callback routine for each node of the queue. If the callback routine returns a nonzero value, the queue processing stops and
/// SetupScanFileQueue returns zero. Issue a SPFILENOTIFY_QUEUESCAN_EX notification and pass a pointer to a FILEPATHS structure as
/// Param1. SPQ_SCAN_USE_CALLBACKEX also checks that the file has a valid signature. Available starting with Windows 2000. On
/// Windows XP only, you can turn off signature checking by combining this flag with SPQ_SCAN_FILE_PRESENCE.
///
///
/// -
/// SPQ_SCAN_INFORM_USER
///
/// Flag specified when all files in the queue pass the check for valid signatures. SetupScanFileQueue informs the user that the
/// operation requires files that are already present on the target. This flag is ignored if SPQ_SCAN_FILE_PRESENCE or
/// SPQ_SCAN_FILE_VALIDITY is not specified. This flag may not be used with SPQ_SCAN_PRUNE_COPY_QUEUE or SPQ_SCAN_PRUNE_DELREN.
///
///
/// -
/// SPQ_SCAN_PRUNE_COPY_QUEUE
///
/// Combined with SPQ_SCAN_FILE_PRESENCE, removes present entries from the copy queue. When combined with SPQ_SCAN_FILE_VALIDITY,
/// removes signed entries from the copy queue. Available starting with Windows 2000. On Windows XP only, files that are also
/// specified in the delete queue or rename queues are not pruned unless SPQ_SCAN_PRUNE_DELREN is specified.
///
///
/// -
/// SPQ_SCAN_USE_CALLBACK_SIGNERINFO
///
/// Available starting with Windows XP. Issues SPFILENOTIFY_QUEUESCAN_SIGNERINFO notification and passes a pointer to a
/// FILEPATHS_SIGNERINFO structure as Param1. Checks each file for a valid signature and reports signature information through the
/// callback function.
///
///
/// -
/// SPQ_SCAN_PRUNE_DELREN
///
/// Combined with SPQ_SCAN_FILE_PRESENCE or SPQ_SCAN_FILE_VALIDITY, removes entries in the delete or rename queue that are also in
/// the copy queue. When combined with SPQ_SCAN_PRUNE_COPY_QUEUE, limits files that are removed from the copy queue to files that
/// are not in the delete or rename queues. Available starting with Windows XP.
///
///
///
///
///
/// Optional handle to the window to own dialog boxes that are presented. This parameter is not used if the Flags parameter does not
/// contain SPQ_SCAN_FILE_PRESENCE or if Flags does not contain SPQ_SCAN_INFORM_USER.
///
///
///
/// Optional pointer to a FileCallback callback function to be called on each node of the copy queue. The notification code passed
/// to the callback function is SPFILENOTIFY_QUEUESCAN. This parameter is required if Flags includes SPQ_SCAN_USE_CALLBACK.
///
///
/// Note You must supply the callback routine specified by CallbackRoutine. The default queue callback routine does not
/// support SetupScanFileQueue.
///
///
///
/// Optional pointer to a context that contains caller-defined data passed to the callback routine pointed to by CallbackRoutine.
///
/// Pointer to a variable that receives the result of the scan operation.
///
/// The function returns a nonzero value if all nodes in the queue were processed.
///
/// If the SPQ_SCAN_USE_CALLBACK flag was set, the value in Result is 0. The callback routine specified by CallbackRoutine is sent
/// the notification SPFILENOTIFY_QUEUESCAN. CallbackRoutine.Param1 specifies a pointer to an array that contains the target path
/// information. The pointer has been cast to an unsigned integer and must be recast to a TCHAR array of MAX_PATH elements before a
/// callback routine can access the information. CallbackRoutine.Param2 is set to SPQ_DELAYED_COPY if the current queue node is in
/// use and cannot be copied until the system is restarted. Otherwise, CallbackRoutine.Param2 takes the value 0.
///
///
/// If SPQ_SCAN_USE_CALLBACK was not set, Result indicates whether the queue passed the presence or validity check as shown in the
/// following table.
///
///
///
/// Return code
/// Description
///
/// -
/// 0
///
/// The queue failed the check or it passed the check, but SPQ_SCAN_INFORM_USER was specified and the user wants new copies of the files.
///
///
/// -
/// 1
///
/// The queue passed the check and, if SPQ_SCAN_INFORM_USER was specified, the user indicated that copying is not required. The copy
/// queue is empty and there are no elements on the delete or rename queues, so the caller can skip queue commit.
///
///
/// -
/// 2
///
/// The queue passed the check and, if SPQ_SCAN_INFORM_USER was specified, the user indicated that copying is not required. The copy
/// queue is empty, but there are elements on the delete or rename queues, so the caller cannot skip queue commit.
///
///
///
///
/// The function returns zero if an error occurred or the callback function returned nonzero. If Result is nonzero, it is the value
/// returned by the callback function that stopped queue processing. If Result is zero, extended error information can be retrieved
/// by a call to GetLastError.
///
///
///
/// Note
///
/// The setupapi.h header defines SetupScanFileQueue as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupscanfilequeuea WINSETUPAPI BOOL SetupScanFileQueueA(
// HSPFILEQ FileQueue, DWORD Flags, HWND Window, PSP_FILE_CALLBACK_A CallbackRoutine, PVOID CallbackContext, PDWORD Result );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupScanFileQueueA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupScanFileQueue(HSPFILEQ FileQueue, SPQ_SCAN Flags, [In, Optional] HWND Window,
[In, Optional] PSP_FILE_CALLBACK CallbackRoutine, [In, Optional] IntPtr CallbackContext, out uint Result);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupSetDirectoryId function associates a directory identifier in an INF file with a specific directory.
///
/// A handle for a loaded INF file.
///
/// A directory identifier (DIRID) to use for an association. This parameter can be NULL. This DIRID must be greater than or
/// equal to DIRID_USER. If an association already exists for this DIRID, it is overwritten. If Id is NULL, the Directory
/// parameter is ignored, and the current set of user-defined DIRIDs is deleted.
///
///
/// A pointer to a null-terminated string that specifies the directory path to associate with Id. This parameter can be
/// NULL. If Directory is NULL, any directory associated with Id is unassociated. No error results if Id is not
/// currently associated with a directory.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
///
///
///
/// SetupSetDirectoryId can be used prior to queuing file copy operations to specify a target location that is only known at runtime.
///
///
/// After setting the directory identifier, this function traverses all appended INF files, and if any of them have unresolved
/// string substitutions, the function attempts to re-apply string substitution to them based on the new DIRID mapping. Because of
/// this, some INF values may change after calling SetupSetDirectoryId.
///
/// DIRID_ABSOLUTE_16BIT is not a valid value for Id, which ensures compatibility with 16-bit setup.
///
/// Note
///
/// The setupapi.h header defines SetupSetDirectoryId as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupsetdirectoryida WINSETUPAPI BOOL
// SetupSetDirectoryIdA( HINF InfHandle, DWORD Id, PCSTR Directory );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetDirectoryIdA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupSetDirectoryId(HINF InfHandle, [Optional] uint Id, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Directory);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupSetDirectoryIdEx function associates a directory identifier in an INF file with a specific directory.
///
/// A handle for a loaded INF file.
///
/// A directory identifier (DIRID) to use for an association. This parameter can be NULL. This DIRID must be greater than or
/// equal to DIRID_USER. If an association already exists for this DIRID, it is overwritten. If Id is zero, the Directory parameter
/// is ignored, and the current set of user-defined DIRIDs is deleted.
///
///
/// A pointer to a null-terminated string that specifies the directory path to associate with Id. This parameter can be
/// NULL. If Directory is NULL, any directory associated with Id is unassociated. No error results if Id is not
/// currently associated with a directory.
///
///
/// This parameter can be set to SETDIRID_NOT_FULL_PATH (1) to indicate that the Directory does not specify a full path.
///
/// If the value of this parameter is not zero the function returns ERROR_INVALID_PARAMETER.
/// If the value of this parameter is not zero the function returns ERROR_INVALID_PARAMETER.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.
///
///
///
/// SetupSetDirectoryIdEx can be used prior to queuing file copy operations to specify a target location that is only known
/// at runtime.
///
///
/// After setting the directory identifier, this function traverses all appended INF files, and if any of them have unresolved
/// string substitutions, the function attempts to re-apply string substitution to them based on the new DIRID mapping. Because of
/// this, some INF values may change after calling SetupSetDirectoryIdEx.
///
/// DIRID_ABSOLUTE_16BIT is not a valid value for Id, which ensures compatibility with 16-bit setup.
///
/// Note
///
/// The setupapi.h header defines SetupSetDirectoryIdEx as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupsetdirectoryidexa WINSETUPAPI BOOL
// SetupSetDirectoryIdExA( HINF InfHandle, DWORD Id, PCSTR Directory, DWORD Flags, DWORD Reserved1, PVOID Reserved2 );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetDirectoryIdExA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupSetDirectoryIdEx(HINF InfHandle, [Optional] uint Id, [Optional, MarshalAs(UnmanagedType.LPTStr)] string Directory,
SETDIRID Flags, [In, Optional] uint Reserved1, [In, Optional] IntPtr Reserved2);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupSetFileQueueAlternatePlatform function associates the file queue with a target platform that is different from
/// the platform running the function. This is done to enable for non-native signature verification.
///
///
/// Handle to an open setup file queue.
///
/// Optional pointer to an SP_ALTPLATFORM_INFO structure passing information about the alternate platform. On Windows 2000, the
/// cbSize member of this structure must be set to sizeof(SP_ALTPLATFORM_INFO_V1). On Windows Server 2003 or Windows XP, the
/// cbSize member of this structure must be set to sizeof(SP_ALTPLATFORM_INFO_V2).
///
///
/// Pointer to a null-terminated string that specifies a catalog that validates any INF files. This parameter may be NULL.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupSetFileQueueAlternatePlatform as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupsetfilequeuealternateplatforma WINSETUPAPI BOOL
// SetupSetFileQueueAlternatePlatformA( HSPFILEQ QueueHandle, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PCSTR
// AlternateDefaultCatalogFile );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetFileQueueAlternatePlatformA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupSetFileQueueAlternatePlatform(HSPFILEQ QueueHandle, in SP_ALTPLATFORM_INFO AlternatePlatformInfo,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string AlternateDefaultCatalogFile);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupSetFileQueueAlternatePlatform function associates the file queue with a target platform that is different from
/// the platform running the function. This is done to enable for non-native signature verification.
///
///
/// Handle to an open setup file queue.
///
/// Optional pointer to an SP_ALTPLATFORM_INFO structure passing information about the alternate platform. On Windows 2000, the
/// cbSize member of this structure must be set to sizeof(SP_ALTPLATFORM_INFO_V1). On Windows Server 2003 or Windows XP, the
/// cbSize member of this structure must be set to sizeof(SP_ALTPLATFORM_INFO_V2).
///
///
/// Pointer to a null-terminated string that specifies a catalog that validates any INF files. This parameter may be NULL.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupSetFileQueueAlternatePlatform as an alias which automatically selects the ANSI or Unicode
/// version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral
/// alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more
/// information, see Conventions for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupsetfilequeuealternateplatforma WINSETUPAPI BOOL
// SetupSetFileQueueAlternatePlatformA( HSPFILEQ QueueHandle, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PCSTR
// AlternateDefaultCatalogFile );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetFileQueueAlternatePlatformA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupSetFileQueueAlternatePlatform(HSPFILEQ QueueHandle, [In, Optional] IntPtr AlternatePlatformInfo,
[Optional, MarshalAs(UnmanagedType.LPTStr)] string AlternateDefaultCatalogFile);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupSetFileQueueFlags function sets the flags on a setup file queue.
///
/// Handle to an open setup file queue.
///
/// Mask of valid flags.
///
///
/// Flag
/// Meaning
///
/// -
/// SPQ_FLAG_VALID 0x001
/// Mask for use with SPQ_FLAG_BACKUP_AWARE.
///
///
///
///
/// Flags for use with SetupSetFileQueueFlags and returned by SetupGetFileQueueFlags.
///
///
/// Flag
/// Meaning
///
/// -
/// SPQ_FLAG_BACKUP_AWARE 0x001
/// If this flag is set, SetupCommitFileQueue issues backup notifications.
///
/// -
/// SPQ_FLAG_ABORT_IF_UNSIGNED 0X002
/// For internal use only.
///
///
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is (0) zero. To get extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupsetfilequeueflags WINSETUPAPI BOOL
// SetupSetFileQueueFlags( HSPFILEQ FileQueue, DWORD FlagMask, DWORD Flags );
[DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetFileQueueFlags")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupSetFileQueueFlags(HSPFILEQ FileQueue, SPQ_FLAG FlagMask, SPQ_FLAG Flags);
///
/// The SetupSetNonInteractiveMode function sets a non-interactive SetupAPI flag that determines whether SetupAPI can
/// interact with a user in the caller's context.
///
///
/// The Boolean value of the non-interactive flag. If NonInteractive is set to TRUE, SetupAPI runs in a non-interactive user
/// mode and if NonInteractive is set to FALSE, SetupAPI runs in an interactive user mode.
///
/// SetupSetNonInteractiveMode returns the previous setting of the non-interactive flag.
///
///
/// Installation applications and co-installers can use this function to control whether SetupAPI can display interactive user
/// interface elements, such as dialog boxes, in the caller's context.
///
///
/// An installation application or an installer can call SetupGetNonInteractiveMode to retrieve the current value of the
/// non-interactive flag.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupsetnoninteractivemode WINSETUPAPI BOOL
// SetupSetNonInteractiveMode( BOOL NonInteractiveFlag );
[DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetNonInteractiveMode")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupSetNonInteractiveMode([MarshalAs(UnmanagedType.Bool)] bool NonInteractiveFlag);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupSetPlatformPathOverride function is used to set a platform path override for a target machine when working with
/// INFs from a different machine. As such, it can refer to a different platform than it is currently running on. For dealing with
/// media sources, it can refer to platforms that are no longer supported, such as Alpha, MIPS, and PPC. It removes the platform
/// path override if none is specified.
///
///
///
/// Pointer to a null-terminated string that contains the replacement platform information. For example, "alpha" or "x86".
/// This parameter may be NULL.
///
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
/// If GetLastError returns ERROR_NOT_ENOUGH_MEMORY, SetupSetPlatformPathOverride was unable to store the Override string.
///
///
///
///
/// SetPlatformPathOverride is used to change the source path when queuing files. If a platform path override has been set by
/// a call to SetPlatformPathOverride, any setup function that queues file copy operations will examine the final component
/// of the source path and if the final component matches the name of the user's platform, replace it with the override string set
/// by SetPlatformPathOverride.
///
///
/// For example, consider a MIPS-platform machine where the platform has been set to Alpha by a call to
/// SetPlatformPathOverride. After the platform path override has been set, a file copy operation is queued with a source
/// path of \pop\top\baz\mips\x.exe, the path will be changed to \pop\top\baz\alpha\x.exe.
///
/// The paths of file copy operations queued before the path override is set are not changed.
///
/// Note
///
/// The setupapi.h header defines SetupSetPlatformPathOverride as an alias which automatically selects the ANSI or Unicode version
/// of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with
/// code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see
/// Conventions for Function Prototypes.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupsetplatformpathoverridea WINSETUPAPI BOOL
// SetupSetPlatformPathOverrideA( PCSTR Override );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetPlatformPathOverrideA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupSetPlatformPathOverride([Optional, MarshalAs(UnmanagedType.LPTStr)] string Override);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupSetSourceList function allows the caller to set the list of installation sources for either the current user or
/// the system (common to all users).
///
///
///
/// Specifies the type of list. This parameter can be a combination of the following values.
/// SRCLIST_SYSTEM
///
/// The list is the per-system Most Recently Used (MRU) list stored in the registry. The caller must be a member of the
/// administrators local group.
///
/// SRCLIST_USER
/// The list is the per-user MRU list stored in the registry.
/// SRCLIST_TEMPORARY
///
/// 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.
///
/// Note One of the SRCLIST_SYSTEM, SRCLIST_USER, or SRCLIST_TEMPORARY flags must be specified.
/// SRCLIST_NOBROWSE
///
/// 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.
///
///
/// Pointer to an array of strings to use as the source list, as specified by the Flags parameter.
/// Number of elements in the array pointed to by SourceList.
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
///
/// Note
///
/// The setupapi.h header defines SetupSetSourceList as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupsetsourcelista WINSETUPAPI BOOL SetupSetSourceListA(
// DWORD Flags, PCSTR *SourceList, UINT SourceCount );
[DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetSourceListA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupSetSourceList(SRCLIST Flags, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPTStr, SizeParamIndex = 2)] string[] SourceList, uint SourceCount);
///
/// The SetupSetThreadLogToken function sets the log context, as represented by a log token for the thread from which this
/// function was called. A subsequent call to SetupGetThreadLogToken made within the same thread retrieves the log token that was
/// most recently set for the thread.
///
/// A log token that is either a system-defined log token or was returned by SetupGetThreadLogToken.
/// None
///
///
/// SetupSetThreadLogToken establishes a log context for the thread from which the function was called. The log context is
/// represented by a log token, which can be retrieved by calling SetupGetThreadLogToken.
///
/// For more information about log tokens, see Log Tokens.
/// For more information about using log tokens, see Setting and Getting a Log Token for a Thread.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupsetthreadlogtoken WINSETUPAPI VOID
// SetupSetThreadLogToken( SP_LOG_TOKEN LogToken );
[DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupSetThreadLogToken")]
public static extern void SetupSetThreadLogToken(ulong LogToken);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupTermDefaultQueueCallback function is called after a queue has finished committing. It frees resources allocated
/// by previous calls to SetupInitDefaultQueueCallback or SetupInitDefaultQueueCallbackEx.
///
///
/// Pointer to the context used by the default callback routine.
///
/// Does not return a value.
/// To get extended error information, call GetLastError.
///
///
/// Regardless of whether you initialized the context used by the default queue callback routine with SetupInitDefaultQueueCallback
/// or SetupInitDefaultQueueCallbackEx, after the queued operations have finished processing, call
/// SetupTermDefaultQueueCallback to release the resources allocated in initializing the context structure. For more
/// information see Initializing and Terminating the Callback Context.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setuptermdefaultqueuecallback WINSETUPAPI VOID
// SetupTermDefaultQueueCallback( PVOID Context );
[DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupTermDefaultQueueCallback")]
public static extern void SetupTermDefaultQueueCallback(IntPtr Context);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
/// The SetupTerminateFileLog function releases resources associated with a file log.
///
/// Handle to the log file as returned by a call to .
///
/// If the function succeeds, the return value is a nonzero value.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupterminatefilelog WINSETUPAPI BOOL
// SetupTerminateFileLog( HSPFILELOG FileLogHandle );
[DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupTerminateFileLog")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupTerminateFileLog(HSPFILELOG FileLogHandle);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupUninstallNewlyCopiedInfs function uninstalls INF files (.inf), precompiled INF files (.pnf), and catalog files
/// (.cat) that are previously installed during the committal of the specified file queue.
///
/// A caller of this function must have administrative privileges; otherwise, the function fails.
///
///
/// Handle to an open and committed file queue. This queue contains the newly installed INF, PNF, or CAT files that
/// SetupUninstallNewlyCopiedInfs uninstalls.
///
///
/// Flags to use with SetupUninstallNewlyCopiedInfs. No flags are defined currently. This parameter must be 0 (zero).
///
/// Reserved. This parameter must be NULL.
///
///
/// If the parameters passed in are valid, the return value is TRUE (nonzero), which does not necessarily mean that any INFs
/// are uninstalled.
///
///
/// If some of the parameters passed in are invalid, the return value is FALSE (zero). To get extended error information,
/// call GetLastError.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupuninstallnewlycopiedinfs WINSETUPAPI BOOL
// SetupUninstallNewlyCopiedInfs( HSPFILEQ FileQueue, DWORD Flags, PVOID Reserved );
[DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupUninstallNewlyCopiedInfs")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupUninstallNewlyCopiedInfs(HSPFILEQ FileQueue, [Optional] uint Flags, [In, Optional] IntPtr Reserved);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupUninstallOEMInf function uninstalls a specified .inf file and any associated .pnf file. If the .inf file was
/// installed with a catalog for signing drivers, the catalog is also removed. A caller of this function must have administrative
/// privileges, otherwise the function fails.
///
///
/// File name, without path, of the .inf file in the Windows Inf directory that is to be uninstalled.
///
/// This parameter can be set as follows.
///
///
/// Flag
/// Meaning
///
/// -
/// SUOI_FORCEDELETE 0x0001
///
/// The SetupUninstallOEMInf function first checks whether there are any devices installed using the .inf file. A device does not
/// need to be present to be detected as using the .inf file. If this flag is not set and the function finds a currently installed
/// device that was installed using this .inf file, the .inf file is not removed. If this flag is set, the .inf file is removed
/// whether the function finds a device that was installed with this .inf file.
///
///
///
///
/// Set to null.
/// This function returns WINSETUPAPI BOOL.
///
/// Note
///
/// The setupapi.h header defines SetupUninstallOEMInf as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupuninstalloeminfa WINSETUPAPI BOOL
// SetupUninstallOEMInfA( PCSTR InfFileName, DWORD Flags, PVOID Reserved );
[DllImport(Lib_SetupAPI, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupUninstallOEMInfA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupUninstallOEMInf([MarshalAs(UnmanagedType.LPTStr)] string InfFileName, SUOI Flags, [In, Optional] IntPtr Reserved);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupVerifyInfFile function verifies the digital signature of the specified INF file by using its corresponding
/// catalog. The verification can be performed against an alternate platform.
///
///
/// The name of the INF file to be verified. This name may include a path.
///
/// An optional pointer to a SP_ALTPLATFORM_INFO_V2 structure that contains information about the alternate platform to use when
/// validating the INF file. This parameter can be Null.
///
///
/// A pointer to an SP_INF_SIGNER_INFO structure that receives information about the INF digital signature, that is, if it is signed.
///
/// This function returns WINSETUPAPI BOOL.
///
/// Note
///
/// The setupapi.h header defines SetupVerifyInfFile as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupverifyinffilea WINSETUPAPI BOOL SetupVerifyInfFileA(
// PCSTR InfName, PSP_ALTPLATFORM_INFO AltPlatformInfo, PSP_INF_SIGNER_INFO_A InfSignerInfo );
[DllImport(Lib_SetupAPI, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupVerifyInfFileA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupVerifyInfFile([MarshalAs(UnmanagedType.LPTStr)] string InfName, in SP_ALTPLATFORM_INFO AltPlatformInfo,
ref SP_INF_SIGNER_INFO_V2 InfSignerInfo);
///
///
/// [This function is available for use in the operating systems indicated in the Requirements section. It may be altered or
/// unavailable in subsequent versions. SetupAPI should no longer be used for installing applications. Instead, use the Windows
/// Installer for developing application installers. SetupAPI continues to be used for installing device drivers.]
///
///
/// The SetupVerifyInfFile function verifies the digital signature of the specified INF file by using its corresponding
/// catalog. The verification can be performed against an alternate platform.
///
///
/// The name of the INF file to be verified. This name may include a path.
///
/// An optional pointer to a SP_ALTPLATFORM_INFO_V2 structure that contains information about the alternate platform to use when
/// validating the INF file. This parameter can be Null.
///
///
/// A pointer to an SP_INF_SIGNER_INFO structure that receives information about the INF digital signature, that is, if it is signed.
///
/// This function returns WINSETUPAPI BOOL.
///
/// Note
///
/// The setupapi.h header defines SetupVerifyInfFile as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that
/// not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions
/// for Function Prototypes.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupverifyinffilea WINSETUPAPI BOOL SetupVerifyInfFileA(
// PCSTR InfName, PSP_ALTPLATFORM_INFO AltPlatformInfo, PSP_INF_SIGNER_INFO_A InfSignerInfo );
[DllImport(Lib_SetupAPI, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupVerifyInfFileA")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetupVerifyInfFile([MarshalAs(UnmanagedType.LPTStr)] string InfName, [In, Optional] IntPtr AltPlatformInfo,
ref SP_INF_SIGNER_INFO_V2 InfSignerInfo);
/// The SetupWriteTextLog function writes a log entry in a SetupAPI text log.
/// A log token that is either a system-defined log token or was returned by SetupGetThreadLogToken.
///
/// A DWORD-typed value that indicates the event category for the log entry. The event categories that can be specified for a log
/// entry are the same as those that can be enabled for a text log. For a list of event categories, see Enabling Event Categories
/// for a SetupAPI Text Log.
///
///
/// A DWORD-typed value that is a bitwise OR of flag values, which specify the following:
///
/// -
///
/// The event level for the log entry. The event levels that can be specified for a log entry are the same as those that can be
/// enabled for a text log. For a list of event level flags, see Setting the Event Level for a SetupAPI Text Log.
///
///
/// -
/// Whether to include a time stamp in the log entry. The time stamp flag value is TXTLOG_TIMESTAMP.
///
/// -
///
/// The change, if any, to the indentation depth of the section and the current log entry. For information about how to use the
/// indentation flags, see Writing Indented Log Entries.
///
///
///
///
///
/// A pointer to a NULL-terminated constant string that contains a printf-compatible format string, which specifies the
/// formatted message to include in the log entry. The comma-separated parameter list that follows MessageStr must match the format
/// specifiers in the format string.
///
///
/// A comma-separated parameter list that matches the format specifiers in the format string that is supplied by MessageStr.
///
/// None
///
///
/// If the value of LogToken was returned by a call to SetupGetThreadLogToken and the corresponding text log section can be found,
/// SetupWriteTextLog writes the log entry in that text log section. If SetupWriteTextLog cannot locate the section,
/// SetupWriteTextLog writes the log entry in the corresponding text log, but does not include the log entry in a section.
///
///
/// If the value of LogToken is one of the system-defined log tokens listed in the following table, SetupWriteTextLog
/// performs the write operation that is indicated for that log token.
///
///
///
/// System-defined log token
/// Write operation
///
/// -
/// LOGTOKEN_NOLOG
/// The log entry is not written to any text log.
///
/// -
/// LOG_TOKEN_UNSPECIFIED
/// The log entry is written to the application installation text log. The log entry is not included in a text log section.
///
/// -
/// LOGTOKEN_SETUPAPI_APPLOG
/// The log entry is written to the application installation text log. The log entry is not included in a text log section.
///
/// -
/// LOGTOKEN_SETUPAPI_DEVLOG
/// The log entry is written to the device installation text log. The log entry is not included in a text log section.
///
///
///
/// Note Setting the value of LogToken to one of the system-defined log tokens does not change the value of the current log
/// token for the thread.
///
/// In addition, SetupWriteTextLog does not write a log entry when any of the following are true:
///
/// -
/// The event level set for the text log is less than the event level that is specified for the log entry.
///
/// -
///
/// The event category for the log entry is not enabled for the text log. For more information about event categories, see Enabling
/// Event Categories for a Text Log.
///
///
///
/// The maximum length, in characters, of a log entry is 336.
/// To write information about a SetupAPI-specific error or a Win32 error in a text log, an application can use SetupWriteTextLogError.
/// For general information about writing log entries in the SetupAPI text logs, see SetupAPI Logging (Windows Vista and Later).
/// For more information about the operation of SetupWriteTextLog, see Calling SetupWriteTextLog.
/// For more information about log tokens, see Log Tokens.
/// For more information about using log tokens, see Setting and Getting a Log Token for a Thread.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupwritetextlog WINSETUPAPI VOID SetupWriteTextLog(
// SP_LOG_TOKEN LogToken, DWORD Category, DWORD Flags, PCSTR MessageStr, ... );
[DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupWriteTextLog")]
public static extern void SetupWriteTextLog(ulong LogToken, uint Category, uint Flags, [MarshalAs(UnmanagedType.LPStr)] string MessageStr, IntPtr args);
///
/// The SetupWriteTextLogError function writes information about a SetupAPI-specific error or a Win32 system error to a
/// SetupAPI text log.
///
/// A log token that is either a system-defined log token or was returned by SetupGetThreadLogToken.
///
/// A value of type DWORD that indicates the event category for the log entry. The event categories that can be specified for a log
/// entry are the same as those that can be enabled for a text log. For a list of event categories, see Enabling Event Categories
/// for a SetupAPI Text Log.
///
///
/// A value of type DWORD that is a bitwise OR of flag values, which specify the following:
///
/// -
///
/// The event level for the log entry. The event levels that can be specified for a log entry are the same as those that can be
/// enabled for a text log. For a list of event level flags, see Setting the Event Level for a Text Log.
///
///
/// -
/// Whether to include a time stamp in the log entry. The time stamp flag value is TXTLOG_TIMESTAMP.
///
/// -
///
/// The change, if any, to the indentation depth of the section and the current log entry. For information about how to use the
/// indentation flags, see Writing Indented Log Entries.
///
///
///
///
///
/// A SetupAPI-specific error code or a Win32 error code. The SetupAPI-specific error codes are listed in Setupapi.h. The Win32
/// error codes are listed in Winerror.h.
///
///
/// A pointer to a NULL-terminated constant string that contains a printf-compatible format string, which specifies the
/// formatted message to include in the log entry.
///
///
/// A comma-separated parameter list that matches the format specifiers in the format string that is supplied by MessageStr.
///
/// None
///
///
/// If an installation application has a SetupAPI-specific error code or a Win32 error code that is associated with an installation
/// error, the application can call SetupWriteTextLogError instead of SetupWriteTextLog to write two entries into a text log.
/// The first entry will be the same as that written by SetupWriteTextLog and the second entry will log the error code and a
/// user-friendly description of the error.
///
///
/// The log token, event category, and flags that a caller supplies affect the operation of SetupWriteTextLogError is the
/// same manner as that described for SetupWriteTextLog.
///
/// SetupWriteTextLogError writes the first log entry in the following format:
/// entry-prefix time_stamp categoryindentation formatted-message
/// SetupWriteTextLogError writes the second log entry in the following format:
/// entry-prefix time_stamp category indentation Error: error-numbererror-description
/// Where:
///
/// -
///
/// The entry-prefix, time-stamp, category, indentation, and formatted-message fields are the same as those described in Format of a
/// Text Log Section Body.
///
///
/// -
/// The error-number field contains the error number.
///
/// -
/// The error-description field contains a user-friendly description of the error.
///
///
/// For general information about writing log entries in the SetupAPI text logs, see SetupAPI Logging (Windows Vista).
/// For more information about the operation of SetupWriteTextLogError, see Calling SetupWriteTextLogError.
/// For more information about log tokens, see Log Tokens.
/// For more information about using log tokens, see Setting and Getting a Log Token for a Thread.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupwritetextlogerror WINSETUPAPI VOID
// SetupWriteTextLogError( SP_LOG_TOKEN LogToken, DWORD Category, DWORD LogFlags, DWORD Error, PCSTR MessageStr, ... );
[DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupWriteTextLogError")]
public static extern void SetupWriteTextLogError(ulong LogToken, uint Category, uint LogFlags, uint Error, [MarshalAs(UnmanagedType.LPStr)] string MessageStr, IntPtr args);
///
/// The SetupWriteTextLogInfLine function writes a log entry in a SetupAPI text log that contains the text of a specified INF
/// file line.
///
/// A log token that is either a system-defined log token or was returned by SetupGetThreadLogToken.
///
/// A value of type DWORD that is a bitwise OR of flag values, which specify the following:
///
/// -
///
/// The event level for the log entry. The event levels that can be specified for a log entry are the same as those that can be
/// enabled for a text log. For a list of event level flags, see Setting the Event Level for a SetupAPI Text Log.
///
///
/// -
/// Whether to include a time stamp in the log entry. The time stamp flag value is TXTLOG_TIMESTAMP.
///
/// -
///
/// The change, if any, to the indentation depth of the section and the current log entry. For information about how to use the
/// indentation flags, see Writing Indented Log Entries.
///
///
///
///
///
/// A handle to the INF file that includes the line of text to be written to the text log. A handle to an INF file is obtained by
/// calling SetupOpenInfFile, which is documented in the Platform SDK.
///
///
/// A pointer to an INF file context that specifies the line of text to be written to the text log. An INF file context for a line
/// is obtained by calling the SetupFind Xxx Line functions. For information about INF files and an INF file context,
/// see the information that is provided in the Platform SDK about using INF files, obtaining an INF file context, and the
/// INFCONTEXT structure.
///
/// None
///
/// SetupWriteTextLogInfLine writes a log entry in the following format:
/// entry-prefix time-stamp inf: indentation inf-line-text ( inf-file-name line line-number )
/// Where:
///
/// -
/// The entry-prefix and time-stamp fields are the same as those described in Format of a Text Log Section Body.
///
/// -
/// The inf-line-text field contains the text of the specified INF file line.
///
/// -
/// The inf-file-name field contains the name of the INF file that contains the specified INF file line.
///
/// -
/// The line-number field contains the line number of the specified line in the INF file.
///
///
///
/// The log token and flags that a caller supplies affect the operation of SetupWriteTextLogInfLine in the same manner as
/// that described for SetupWriteTextLog and SetupWriteTextLogError. In addition, SetupWriteTextLogInfLine uses the event
/// category TXTLOG_INF.
///
/// For general information about writing log entries in the SetupAPI text logs, see SetupAPI Logging (Windows Vista).
/// For more information about the operation of SetupWriteTextLogInfLine, see Calling SetupWriteTextLogInfLine.
/// For more information about the various types of log tokens, see Log Tokens.
/// For more information about using log tokens, see Setting and Getting a Log Token for a Thread.
///
// https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupwritetextloginfline WINSETUPAPI VOID
// SetupWriteTextLogInfLine( SP_LOG_TOKEN LogToken, DWORD Flags, HINF InfHandle, PINFCONTEXT Context );
[DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)]
[PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupWriteTextLogInfLine")]
public static extern void SetupWriteTextLogInfLine(ulong LogToken, uint Flags, HINF InfHandle, in INFCONTEXT Context);
/// Provides a handle to a log file.
[StructLayout(LayoutKind.Sequential)]
public struct HSPFILELOG : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HSPFILELOG(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HSPFILELOG NULL => new HSPFILELOG(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(HSPFILELOG h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HSPFILELOG(IntPtr h) => new HSPFILELOG(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HSPFILELOG h1, HSPFILELOG h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HSPFILELOG h1, HSPFILELOG h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HSPFILELOG h && handle == h.handle;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
///
/// An SP_ALTPLATFORM_INFO structure specifies, for a given computer, the version of the operating system and the computer's
/// processor architecture.
///
///
/// For information about the major and minor version numbers of the operating system, see the Microsoft Windows SDK documentation
/// for GetVersionEx and OSVERSIONINFO.
///
// https://docs.microsoft.com/en-us/previous-versions/windows/hardware/previsioning-framework/ff552338(v=vs.85) typedef struct {
// DWORD cbSize; DWORD Platform; DWORD MajorVersion; DWORD MinorVersion; WORD ProcessorArchitecture; WORD Reserved; }
// SP_ALTPLATFORM_INFO, *PSP_ALTPLATFORM_INFO;
[PInvokeData("Setupapi.h")]
[StructLayout(LayoutKind.Sequential)]
public struct SP_ALTPLATFORM_INFO
{
///
/// Specifies the size, in bytes, of an SP_ALTPLATFORM_INFO structure. Starting with Windows XP, the cbSize member of this
/// structure must be set to sizeof(SP_ALTPLATFORM_INFO_V2). For all earlier versions of Windows, the cbSize member of this
/// structure must be set to sizeof(SP_ALTPLATFORM_INFO_V1).
///
public uint cbSize;
///
/// Specifies one of the following operating system constants.
///
///
/// Platform constant
/// Meaning
///
/// -
/// VER_PLATFORM_WIN32_WINDOWS
/// Windows 95/98/Millennium(Me) versions
///
/// -
/// VER_PLATFORM_WIN32_NT
/// Windows NT 4.0 and later versions of the NT-based operating system
///
///
///
public uint Platform;
/// Specifies the major version number of the operating system.
public uint MajorVersion;
/// Specifies the minor version number of the operating system.
public uint MinorVersion;
///
/// Specifies one of the following processor architecture constants.
///
///
/// Processor architecture constant
/// Meaning
///
/// -
/// PROCESSOR_ARCHITECTURE_INTEL
/// The alternative platform is an x86-based processor architecture.
///
/// -
/// PROCESSOR_ARCHITECTURE_AMD64
/// The alternative platform is an x64-based processor architecture.
///
/// -
/// PROCESSOR_ARCHITECTURE_IA64
/// The alternative platform is an Itanium-based processor architecture.
///
/// -
/// PROCESSOR_ARCHITECTURE_ALPHA
///
/// The alternative platform is an Alpha processor architecture that is running Windows NT 4.0. Only a system that is running
/// Windows 2000 Print Server or Windows XP Professional Print Server can specify this value.
///
///
///
///
public ProcessorArchitecture ProcessorArchitecture;
/// Must be set to zero.
public ushort Reserved;
}
/// Provides a for that is disposed using .
public class SafeHDSKSPC : SafeHANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHDSKSPC(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHDSKSPC() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HDSKSPC(SafeHDSKSPC h) => h.handle;
///
protected override bool InternalReleaseHandle() => SetupDestroyDiskSpaceList(handle);
}
/// Provides a for that is disposed using .
public class SafeHINF : SafeHANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHINF(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHINF() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HINF(SafeHINF h) => h.handle;
///
protected override bool InternalReleaseHandle() { SetupCloseInfFile(handle); return true; }
}
/// Provides a for that is disposed using .
public class SafeHSPFILELOG : SafeHANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHSPFILELOG(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHSPFILELOG() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HSPFILELOG(SafeHSPFILELOG h) => h.handle;
///
protected override bool InternalReleaseHandle() => SetupTerminateFileLog(handle);
}
/// Provides a for that is disposed using .
public class SafeHSPFILEQ : SafeHANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHSPFILEQ(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHSPFILEQ() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HSPFILEQ(SafeHSPFILEQ h) => h.handle;
///
protected override bool InternalReleaseHandle() => SetupCloseFileQueue(handle);
}
}
}