namespace Vanara.PInvoke; /// Items from the SetupAPI.dll public static partial class SetupAPI { private const string Lib_SetupAPI = "setupapi.dll"; /// /// /// [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 FileCallback callback function is used by a few setup functions. The PSP_FILE_CALLBACK type defines a pointer to this /// callback function. FileCallback is a placeholder for the application-defined function name. /// /// For more information, see Notifications, Creating a Custom Queue Callback Routine, and Creating a Cabinet Callback Routine. /// /// The context information about the queue notification that is returned to the callback function. /// The event that triggers the call to the callback function. /// The additional notification information. The value is dependent on the notification that is being returned. /// The additional notification information. The value is dependent on the notification that is being returned. /// None // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nc-setupapi-psp_file_callback_a PSP_FILE_CALLBACK_A PspFileCallbackA; // UINT PspFileCallbackA( PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2 ) {...} [UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)] [PInvokeData("setupapi.h", MSDNShortId = "NC:setupapi.PSP_FILE_CALLBACK_A")] public delegate uint PSP_FILE_CALLBACK(IntPtr Context, uint Notification, IntPtr Param1, IntPtr Param2); /// /// /// [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.] /// /// /// InstallHinfSection is an entry-point function exported by Setupapi.dll that you can use to execute a section of an .inf /// file. InstallHinfSection can be invoked by calling the Rundll32.exe utility as described in the Remarks section. /// /// The prototype for the InstallHinfSection function follows the form of all entry-point functions used with Rundll32.exe. /// /// If a file is copied or modified, the caller of this function is required have privileges to write into the target directory. If /// there are any services being installed, the caller of this function is required have access to the Service Control Manager. /// /// /// The parent window handle. Typically hwnd is Null. /// Reserved and should be Null. /// Pointer to buffer containing the command line. You should use a null-terminated string. /// Reserved and should be zero. /// None /// /// Note that three exports exist: InstallHinfSection (for RunDll32), InstallHinfSectionA, and InstallHinfSectionW. /// /// To run an Install section of a specified .inf file, you can invoke InstallHinfSection with the Rundll32.exe by /// using the following syntax. /// /// RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection<section><mode><path> /// This passes "<section><mode><path>" to CmdLineBuffer. /// /// Alternatively, your program may call InstallHinfSection, InstallHinfSectionA, or InstallHinfSectionW /// directly, setting the CmdLineBuffer parameter to the following. /// /// /// "<section> <mode> <path>" /// /// /// Where path is the full path to the .inf file, mode is the reboot mode parameter, and section is any Install section in /// the .inf file. The comma separator between SETUPAPI.DLL and InstallHinfSection on the command line is required. Note that /// there cannot be any white space on the command line between the comma and SETUPAPI.DLL or InstallHinfSection. /// /// It is recommended that you specify the full path to the .inf file as path. /// You may specify any Install section in the .inf file as section. No spaces are allowed. /// /// You should use a combination of the following values for mode. You must include 128 to set the default path of the installation /// to the location of the INF, otherwise a system-provided INF is assumed. Add values to specify rebooting. Note that only the /// values 128 or 132 are recommended, other values may cause the computer to reboot unnecessarily or not reboot when it required. /// /// /// /// Value /// Description /// /// /// 0 /// System provided INF. /// /// /// 128 /// Set the default path of the installation to the location of the INF. This is the typical setting. /// /// /// +0 /// Never reboot the computer. /// /// /// +1 /// Reboot the computer in all cases. /// /// /// +2 /// Always ask the users if they want to reboot. /// /// /// +3 /// Reboot the computer if necessary without asking user for permission. /// /// /// +4 /// If a reboot of the computer is necessary, ask the user for permission before rebooting. /// /// /// /// For example, the following command line runs the DefaultInstall section of the Shell.inf file. If Setup determines a reboot is /// required, the user is will be prompted with a "Reboot the computer, Yes/No" dialog box. /// /// RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 C:\WINDOWS\INF\SHELL.INF /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-installhinfsectiona void InstallHinfSectionA( HWND // Window, HINSTANCE ModuleHandle, PCSTR CommandLine, INT ShowCommand ); [DllImport(Lib_SetupAPI, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.InstallHinfSectionA")] public static extern void InstallHinfSection([Optional] HWND Window, [Optional] HINSTANCE ModuleHandle, [MarshalAs(UnmanagedType.LPTStr)] string CommandLine, ShowWindowCommand ShowCommand); /// /// /// [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 SetupAddInstallSectionToDiskSpaceList function searches for CopyFile and DelFile lines in an /// Install section of an INF file. The function then adds the file operations specified in those sections to a disk-space list. /// /// /// Handle to a disk-space list. /// /// Handle to an open INF file that contains the Install section to be searched. If ListInfHandle is not specified, the INF /// file must also contain the section specified by SectionName. /// /// /// This parameter, if specified, provides the handle to the INF file that contains the SourceDisksFiles sections. Otherwise /// that section is assumed to exist in the INF file specified by InfHandle. /// /// /// Name of the Install section to be added to the disk-space list. You should use a null-terminated string. /// /// 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. // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupaddinstallsectiontodiskspacelista WINSETUPAPI BOOL // SetupAddInstallSectionToDiskSpaceListA( 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.SetupAddInstallSectionToDiskSpaceListA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupAddInstallSectionToDiskSpaceList(HDSKSPC DiskSpace, HINF InfHandle, [Optional] HINF LayoutInfHandle, [MarshalAs(UnmanagedType.LPTStr)] string SectionName, IntPtr Reserved1 = default, uint Reserved2 = default); /// /// /// [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 SetupAddSectionToDiskSpaceList function adds to a disk-space list all the file delete or copy operations listed in a /// Copy Files or Delete Files section of an INF file. /// /// Target disk compression is ignored by this function. Files are assumed to occupy their full size on the target disk. /// /// 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 named by SectionName. /// /// /// Optional handle to an open INF file that contains the section specified by SectionName. Otherwise, InfHandle is assumed to /// contain this section. /// /// /// Name of the Copy Files or Delete Files section that contains the file operations to add to the disk-space list. /// Use a null-terminated string. /// /// /// Type of file operation to be added to 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. /// /// This function requires a Windows INF file. Some older INF file formats may not be supported. // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupaddsectiontodiskspacelista WINSETUPAPI BOOL // SetupAddSectionToDiskSpaceListA( 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.SetupAddSectionToDiskSpaceListA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupAddSectionToDiskSpaceList(HDSKSPC DiskSpace, HINF InfHandle, [Optional] HINF ListInfHandle, [MarshalAs(UnmanagedType.LPTStr)] string SectionName, FILEOP Operation, IntPtr Reserved1 = default, uint Reserved2 = default); /// /// /// [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 SetupAddToDiskSpaceList function adds a single delete or copy operation to a disk-space list. To add all the file /// operations in a section of an INF file, use either SetupAddSectionToDiskSpaceList, or SetupAddInstallSectionToDiskSpaceList. /// /// Target disk compression is ignored by this function. Files are assumed to occupy their full size on the target disk. /// /// Handle to the disk-space list. /// /// File name of the file to be added to the disk-space list. You should use a null-terminated string that specifies a fully /// qualified path. Otherwise, the path must be relative to the current directory. /// /// /// Uncompressed size of the file as it will exist in the target directory, in bytes. You can use SetupGetSourceFileSize to retrieve /// this information from an INF file. This parameter is ignored for FILEOP_DELETE operations. /// /// /// File operation to be added to 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. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupaddtodiskspacelista WINSETUPAPI BOOL // SetupAddToDiskSpaceListA( HDSKSPC DiskSpace, PCSTR TargetFilespec, LONGLONG FileSize, UINT Operation, PVOID Reserved1, UINT // Reserved2 ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupAddToDiskSpaceListA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupAddToDiskSpaceList(HDSKSPC DiskSpace, [MarshalAs(UnmanagedType.LPTStr)] string TargetFilespec, long FileSize, FILEOP Operation, IntPtr Reserved1 = default, uint Reserved2 = default); /// /// /// [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 SetupAddToSourceList function appends a value to the list of installation sources for either the current user or the /// system. If the value already exists, it is removed first, so that duplicate entries are not created. /// /// A caller of this function is required have administrative privileges, otherwise the function fails. /// /// /// List to which the source will be appended. This parameter can be any combination of the following values. /// SRCLIST_SYSTEM /// Add the source to the per-system list. The caller must be an administrator. /// SRCLIST_USER /// Add the source to the per-user list. /// SRCLIST_SYSIFADMIN /// /// If the caller is an administrator, the source is added to the per-system list; if the caller is not a member of the /// administrators local group, the source is added to the per-user list for the current user. /// /// /// Note If a temporary list is currently in use (see SetupSetSourceList), the preceding flags are ignored and the source is /// added to the temporary list. /// /// SRCLIST_APPEND /// Add the source to the end of the list. If this flag is not specified, the source is added to the beginning of the list. /// /// Pointer to the source to be added to the list. You should use a null-terminated string. /// /// 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-setupaddtosourcelista WINSETUPAPI BOOL // SetupAddToSourceListA( DWORD Flags, PCSTR Source ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupAddToSourceListA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupAddToSourceList(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 SetupAdjustDiskSpaceList function adjusts the amount of required space for a specified drive. /// /// Handle to a disk-space list. /// /// Specifies a valid Win32 drive root. An entry is added to the disk-space list if the specified drive is not currently in the /// disk-space list. /// /// /// Specifies the amount of space to add or remove. Use a negative number to remove space and use a positive number to add space. /// /// Unused, must be zero. /// Unused, 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. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupadjustdiskspacelista WINSETUPAPI BOOL // SetupAdjustDiskSpaceListA( HDSKSPC DiskSpace, LPCSTR DriveRoot, LONGLONG Amount, PVOID Reserved1, UINT Reserved2 ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupAdjustDiskSpaceListA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupAdjustDiskSpaceList(HDSKSPC DiskSpace, [MarshalAs(UnmanagedType.LPTStr)] string DriveRoot, long Amount, IntPtr Reserved1 = default, uint Reserved2 = default); /// /// /// [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 SetupBackupError function generates a dialog box that informs the user of a backup error. /// /// Handle to the parent window for this dialog box. /// /// Optional pointer to a null-terminated string specifying the error dialog box title. If this parameter is NULL, the /// default title of "Backup Error" (localized) is used. /// /// /// Pointer to a null-terminated string specifying the full path of the source file that is being backed up. /// /// /// Optional pointer to a null-terminated string specifying the full path of the backup name of the file. This parameter can /// be NULL. /// /// If an error occurs, this member is the system error code. If no error has occurred, it is NO_ERROR. /// /// Flags that control 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 to get the user's attention 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. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupbackuperrora WINSETUPAPI UINT SetupBackupErrorA( // 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.SetupBackupErrorA")] public static extern uint SetupBackupError(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 SetupCancelTemporarySourceList function cancels any temporary list and no-browse behavior and reestablishes standard /// list behavior. /// /// /// /// If a temporary list was in effect, the return value is a nonzero value. Otherwise, the return value is zero. To get extended /// error information, call GetLastError. /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupcanceltemporarysourcelist WINSETUPAPI BOOL SetupCancelTemporarySourceList(); [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupCancelTemporarySourceList")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupCancelTemporarySourceList(); /// /// /// [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 SetupCloseFileQueue function destroys a setup file queue. /// /// Handle to an open setup file queue. /// This function does not return a value. /// /// The SetupCloseFileQueue function does not flush the queue; pending operations are not performed. To commit a file queue /// before closing it call SetupCommitFileQueue. /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupclosefilequeue WINSETUPAPI BOOL SetupCloseFileQueue( // HSPFILEQ QueueHandle ); [DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupCloseFileQueue")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupCloseFileQueue(HSPFILEQ QueueHandle); /// /// /// [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 SetupCloseInfFile function closes the INF file opened by a call to SetupOpenInfFile. This function closes any INF /// files appended to it by calling SetupOpenAppendInfFile. /// /// /// Handle to the INF file to be closed. /// This function does not return a value. // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupcloseinffile WINSETUPAPI VOID SetupCloseInfFile( // HINF InfHandle ); [DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupCloseInfFile")] public static extern void SetupCloseInfFile(HINF InfHandle); /// /// /// [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 SetupCloseLog function closes the log files. /// /// This function does not return a value. /// 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-setupcloselog WINSETUPAPI VOID SetupCloseLog(); [DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupCloseLog")] public static extern void SetupCloseLog(); /// /// /// [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 SetupCommitFileQueue function performs file operations queued on a setup file queue. /// /// The best practice is to collect all the required file operations for the file queue and commit the queue only once because a /// file queue cannot be reused after it has been committed. If additional processing of the queue is required after it has been /// committed, the handle to the queue should be closed and a new file queue created. For more information, see Committing a Queue. /// /// If a file is modified, the caller of this function is required have privileges to write into the target directory. /// /// Optional handle to a window to use as the parent of any progress dialog boxes. /// Handle to a setup file queue, as returned by SetupOpenFileQueue. /// /// Pointer to an optional callback routine to be notified of various significant events that are in the queue processing. For more /// information, see Default Queue Callback Routine or FileCallback If the callback routine is null, /// SetupCommitFileQueue returns TRUE and the error is 0 or NO_ERROR. /// /// /// Value that is passed to the callback function supplied by the MsgHandler parameter. If the default callback routine has been /// specified as MsgHandler, this context must be the context returned from SetupInitDefaultQueueCallback or SetupInitDefaultQueueCallbackEx. /// /// /// 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 callback routine specified in MsgHandler should be compatible with the parameters that SetupCommitFileQueue passed to /// it during a queue commit. /// /// /// If Unicode is defined in your callback application, and you specify MsgHandler as the default queue callback routine, the /// callback routine will expect Unicode parameters. Otherwise, the default queue callback routine will expect ANSI parameters. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupcommitfilequeuea WINSETUPAPI BOOL // SetupCommitFileQueueA( HWND Owner, HSPFILEQ QueueHandle, PSP_FILE_CALLBACK_A MsgHandler, PVOID Context ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupCommitFileQueueA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupCommitFileQueue([Optional] HWND Owner, HSPFILEQ QueueHandle, 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 SetupConfigureWmiFromInfSection function configures the security of the WMI data that is exposed by an INF file when /// passed to the [DDInstall.WMI] section. /// /// /// It is used to establish security when the version of SetupAPI on the system does not natively support the WMI security /// information provided in the DDInstall section of the INF file. /// /// /// A handle to an open INF file. /// /// Name of the section in the INF file that contains WMI security information. This should be in the form of[DDinstall.WMI]. /// /// /// This parameter can be set as follows. /// /// /// Flag /// Meaning /// /// /// SCWMI_CLOBBER_SECURITY 0x0001 /// /// If and only if this flag is set does the security information passed to this function override any security information set /// elsewhere in the INF file. If this flag does not exist and no security information exists in the INF file, the security is set. /// /// /// /// /// This function returns WINSETUPAPI BOOL. /// /// In previous SetupAPI versions, WMI information in INF files is exposed to all users, and access could only be limited by /// correctly writing binary data to a registry key. Current versions read and process WMI security information provided by the /// DDInstall section of an INF file. /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupconfigurewmifrominfsectiona WINSETUPAPI BOOL // SetupConfigureWmiFromInfSectionA( HINF InfHandle, PCSTR SectionName, DWORD Flags ); [DllImport(Lib_SetupAPI, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupConfigureWmiFromInfSectionA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupConfigureWmiFromInfSection(HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string SectionName, SCWMI 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 SetupCopyError function generates a dialog box to notify a user of a copy file error. /// /// The handle to the parent window for this dialog box. /// /// An optional pointer to a null-terminated string that specifies the dialog box title. /// /// This parameter can be NULL. If this parameter is NULL, the default title of "Copy Error" (localized to the system /// language) is used. /// /// /// /// An optional pointer to a null-terminated string that specifies the name of the disk to insert. /// /// This parameter can be NULL. If this parameter is NULL, the default name "(Unknown)" (localized to the system /// language) is used. /// /// /// /// A pointer to the path component of the source file where an operation fails, for example, F:\x86. /// Use a null-terminated string. /// /// /// A pointer to a null-terminated string that specifies the filename part of the file where an operation fails. /// /// Use a null-terminated string. This filename is displayed if the user clicks on the Details or Browse /// buttons. The SetupCopyError function looks for the file that uses 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. /// /// /// /// /// An optional pointer to a null-terminated string that specifies the full path of the target file for rename and copy operations. /// /// /// Use a null-terminated string. This parameter can be NULL. If TargetPathFile is not specified, "(Unknown)" /// (localized to the system language) is used. /// /// /// /// If an error occurs, this member is the System Error Code. /// If an error does not occur, it is NO_ERROR. /// /// /// The flags that control display formatting and behavior of a dialog box. /// This parameter can be one of the following flags. /// IDF_NOBROWSE /// Do not display the browse option. /// IDF_NOSKIP /// Do not display the skip file option. /// IDF_NODETAILS /// Do not display the details option. /// If this flag is set, the TargetPathFile and Win32ErrorCode parameters can be omitted. /// IDF_NOCOMPRESSED /// Do not check for compressed versions of the source file. /// IDF_OEMDISK /// The operation source is a disk that a hardware manufacturer provides. /// IDF_NOBEEP /// Prevents the dialog box from beeping to get the user's attention when it first appears. /// IDF_NOFOREGROUND /// Prevents the dialog box from becoming the foreground window. /// IDF_WARNIFSKIP /// Warns the user that skipping a file can affect the installation. /// /// /// /// An optional pointer to a variable in which this function returns the path (not including the filename) of the location that a /// user specifies in the dialog box. You should use a null-terminated string. /// /// /// The null-terminated string should not exceed the size of the destination buffer. To avoid insufficient buffer errors, /// PathBuffer should be at least MAX_PATH. For more information, see the Remarks section of this topic. /// /// /// /// The size of the buffer that PathBuffer points to, in characters. /// The buffer size should be at least MAX_PATH characters, including the null terminator. /// /// /// An optional pointer to a variable in which this function returns the required buffer size, in characters, including 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 0 (zero), the function puts the buffer size /// that is needed to hold the specified data into the variable pointed to by PathRequiredSize. /// /// If the function succeeds, the return value is NO_ERROR. Otherwise, the return value is one of the specified values. /// To avoid insufficient buffer errors, ReturnBuffer should be at least MAX_PATH. /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupcopyerrora WINSETUPAPI UINT SetupCopyErrorA( HWND // hwndParent, PCSTR DialogTitle, PCSTR DiskName, PCSTR PathToSource, PCSTR SourceFile, PCSTR TargetPathFile, UINT Win32ErrorCode, // DWORD Style, PSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupCopyErrorA")] public static extern uint SetupCopyError(HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? DialogTitle, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? DiskName, [MarshalAs(UnmanagedType.LPTStr)] string PathToSource, [MarshalAs(UnmanagedType.LPTStr)] string SourceFile, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? TargetPathFile, Win32Error Win32ErrorCode, IDF Style, [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 SetupCopyOEMInf function copies a specified .inf file to the %windir%/Inf directory. /// A caller of this function is required have administrative privileges, otherwise the function fails. /// /// /// Full path to the source .inf file. You should use a null-terminated string. This path should not exceed MAX_PATH in size, /// including the terminating NULL. /// /// /// Source location information to be stored in the precompiled .inf (.pnf). This location information is specific to the source /// media type specified. You should use a null-terminated string. This path should not exceed MAX_PATH in size, including /// the terminating NULL. /// /// /// Source media type referenced by the location information. This parameter may be one of the following values. /// /// /// Value /// Meaning /// /// /// SPOST_NONE /// No source media information is stored in the .pnf file. The value of OEMSourceMediaLocation is ignored in this case. /// /// /// SPOST_PATH /// /// OEMSourceMediaLocation contains a path to the source media. For example, if the media is on a floppy, this path might be "A:\". /// If OEMSourceMediaLocation is NULL, the path is assumed to be the path where the .inf is located. If the .inf has a corresponding /// .pnf in that location, the .pnf file's source media information is transferred to the destination .pnf file. /// /// /// /// SPOST_URL /// /// OEMSourceMediaLocation contains a universal resource locator (URL) that specifies the Internet location from where the /// .inf/driver files were retrieved. If OEMSourceMediaLocation is NULL, it is assumed that the default Code Download Manager /// location was used. /// /// /// /// /// /// Specifies how the .inf file is copied into the .inf directory. The following flags can be combined. /// /// /// Value /// Meaning /// /// /// SP_COPY_DELETESOURCE /// Delete source file on successful copy. /// /// /// SP_COPY_REPLACEONLY /// /// Copy only if this file already exists in the Inf directory. This flag could be used to update the source location information /// for an existing .inf. /// /// /// /// SP_COPY_NOOVERWRITE /// /// Copy only if the specified files do not currently exist in the Inf directory. If the .inf does currently exist, this API fails /// and GetLastError returns ERROR_FILE_EXISTS. In this case, the existing .inf file's filename is placed into the appropriate field /// in the destination .inf file's information output buffers. /// /// /// /// SP_COPY_OEMINF_CATALOG_ONLY /// /// The specified .inf file's corresponding catalog files is copied to %windir%\Inf. If this flag is specified, the destination /// filename information is entered upon successful return if the specified .inf file already exists in the Inf directory. /// /// /// /// /// /// Pointer to a buffer to receive the .inf file name assigned to it at the time it was copied to the Inf directory. The buffer, if /// specified, should typically be MAX_PATH in length. If the SP_COPY_NOOVERWRITE flag is specified and the /// SetupCopyOEMInf function fails with a return code of ERROR_FILE_EXISTS, this buffer contains the name of the existing /// .inf file. If the SP_COPY_OEMINF_CATALOG_ONLY flag is specified, this buffer contains the destination .inf filename if the .inf /// file is already present in the Inf directory. Otherwise, this buffer is set to the empty string. This parameter can be NULL. /// /// /// Size of the DestinationInfFileName buffer, in characters, or zero if the buffer is not specified. If DestinationInfFileName is /// specified and this buffer size is less than the size required to return the destination .inf filename (including full path), /// this function fails. In this case GetLastError returns ERROR_INSUFFICIENT_BUFFER. /// /// /// Pointer to a variable that receives the size (in characters) required to store the destination .inf file name including a /// terminating NULL. If the SP_COPY_OEMINF_CATALOG_ONLY flag is specified, this variable receives a string length only if /// the .inf file already exists in the Inf directory. Otherwise, this variable is set to zero. This parameter can be NULL. /// /// /// Pointer to a string that is set upon successful return (or ERROR_FILE_EXISTS) to point to the beginning of the filename /// component of the path stored in the DestinationInfFileName parameter. If the SP_COPY_OEMINF_CATALOG_ONLY flag is specified, the /// DestinationInfFileName parameter may be an empty string. In this case, the character pointer is set to NULL upon /// successful return. This parameter can be NULL. /// /// This function returns WINSETUPAPI BOOL. /// /// /// The SetupCopyOEMInf function copies a specified .inf file into the %windir%\Inf directory. SetupCopyOEMInf does /// not recopy the file if it finds that a binary image of the specified .inf file already exists in the Inf directory with the same /// name or a name of the form OEM*.inf. When SetupCopyOEMInf copies a file, it renames the copied file to OEM*.inf. Name /// provided is unique and cannot be predicted. /// /// SetupCopyOEMInf uses the following procedure to determine if the .inf file already exists in the Inf directory: /// /// All .inf files with names of the form OEM*.inf are enumerated and any files that have the same file size as the specified .inf /// file are binary compared. /// /// /// The Inf directory is searched for the source filename of the .inf file. If an .inf file of the same name exists and is the same /// size as that of the specified .inf file, the two files are binary compared to determine if they are identical. /// /// /// If the specified .inf file already exists a further check is performed to determine if the specified .inf file contains a /// CatalogFile= entry in its [Version] section. If it does, the .inf files's %windir%\Inf primary filename with a ".cat" extension /// is used to determine if the catalog is already installed. If there is a catalog installed, but it is not the same as the catalog /// associated with the source .inf, this is not considered to be a match and enumerations continue. It is possible to have multiple /// identical .inf files with unique catalogs contained in %windir%\Inf directory. If an existing match is not found, the .inf and /// .cat files are installed under a new and unique name. /// /// OEM .inf files that do not specify a CatalogFile= entry are considered invalid with respect to digital signature verification. /// /// In cases where the .inf file must be copied to the %windir%\Inf directory, any digital signature verification failures are reported. /// /// /// If the .inf and .cat files already exist, these existing filenames are used and the file replacement behavior is based on the /// specified CopyStyle flags. Replacement behavior refers only to the source media information stored in the .pnf. Existing .inf, /// .pnf, and .cat files are not modified. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupcopyoeminfa WINSETUPAPI BOOL SetupCopyOEMInfA( PCSTR // SourceInfFileName, PCSTR OEMSourceMediaLocation, DWORD OEMSourceMediaType, DWORD CopyStyle, PSTR DestinationInfFileName, DWORD // DestinationInfFileNameSize, PDWORD RequiredSize, PSTR *DestinationInfFileNameComponent ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupCopyOEMInfA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupCopyOEMInf([MarshalAs(UnmanagedType.LPTStr)] string SourceInfFileName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? OEMSourceMediaLocation, uint OEMSourceMediaType, CopyStyle CopyStyle, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder? DestinationInfFileName, uint DestinationInfFileNameSize, out uint RequiredSize, [MarshalAs(UnmanagedType.LPTStr)] out StrPtrAuto DestinationInfFileNameComponent); /// /// /// [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 SetupCreateDiskSpaceList function creates a disk-space list. /// /// Unused, must be zero. /// Unused, must be zero. /// /// This parameter can be the following value. /// SPDSL_IGNORE_DISK /// /// File operations added to the list will ignore files that already exist on the disk. For example, if the disk contains a /// 5000-byte file, C:\MyDir\MyFile, and you add a Copy operation to the disk-space list for a new version, C:\MyDir\MyFile, that is /// 6500 bytes, the space required will be 6500 bytes (instead of 1500 bytes, which is the value returned if you do not set SPDSL_IGNORE_DISK). /// /// /// /// If the function succeeds, it returns a handle to the disk-space list. /// If the function fails, it returns null. To get extended error information, call GetLastError. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupcreatediskspacelista WINSETUPAPI HDSKSPC // SetupCreateDiskSpaceListA( PVOID Reserved1, DWORD Reserved2, UINT Flags ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupCreateDiskSpaceListA")] public static extern SafeHDSKSPC SetupCreateDiskSpaceList([In, Optional] IntPtr Reserved1, [In, Optional] uint Reserved2, SPDSL 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 SetupDecompressOrCopyFile function copies a file, decompressing it if necessary. /// If a file is copied, the caller of this function is required have privileges to write into the target directory. /// /// /// File name of the file to be copied. You should use a null-terminated string. This parameter can be NULL. If /// CompressionType is not specified and the SetupDecompressOrCopyFile function does not find the file specified in /// SourceFileName, the function searches for the file with up to two alternate, "compressed-form" names. For example, if the file /// is F:\x86\cmd.exe and it is not found, the function searches for F:\x86\cmd.ex_ and, if that is not found, F:\x86\cmd.ex$ is /// searched for. If CompressionType is specified, no additional processing is performed on the filename; the file must exist /// exactly as specified or the function fails. /// /// /// Exact name of the target file that will be created by decompressing or copying the source file. You should use a /// null-terminated string. /// /// /// Optional pointer to the compression type used on the source file. You can determine the compression type by calling /// SetupGetFileCompressionInfo. If this value is FILE_COMPRESSION_NONE, the file is copied (not decompressed) regardless of any /// compression in use on the source. If CompressionType is not specified, this routine determines the compression type automatically. /// /// /// The SetupDecompressOrCopyFile function returns a system error code that indicates the outcome of the operation. /// To get extended error information, call GetLastError. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdecompressorcopyfilea WINSETUPAPI DWORD // SetupDecompressOrCopyFileA( PCSTR SourceFileName, PCSTR TargetFileName, PUINT CompressionType ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDecompressOrCopyFileA")] public static extern uint SetupDecompressOrCopyFile([MarshalAs(UnmanagedType.LPTStr)] string SourceFileName, [MarshalAs(UnmanagedType.LPTStr)] string TargetFileName, in FILE_COMPRESSION CompressionType); /// /// /// [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 SetupDecompressOrCopyFile function copies a file, decompressing it if necessary. /// If a file is copied, the caller of this function is required have privileges to write into the target directory. /// /// /// File name of the file to be copied. You should use a null-terminated string. This parameter can be NULL. If /// CompressionType is not specified and the SetupDecompressOrCopyFile function does not find the file specified in /// SourceFileName, the function searches for the file with up to two alternate, "compressed-form" names. For example, if the file /// is F:\x86\cmd.exe and it is not found, the function searches for F:\x86\cmd.ex_ and, if that is not found, F:\x86\cmd.ex$ is /// searched for. If CompressionType is specified, no additional processing is performed on the filename; the file must exist /// exactly as specified or the function fails. /// /// /// Exact name of the target file that will be created by decompressing or copying the source file. You should use a /// null-terminated string. /// /// /// Optional pointer to the compression type used on the source file. You can determine the compression type by calling /// SetupGetFileCompressionInfo. If this value is FILE_COMPRESSION_NONE, the file is copied (not decompressed) regardless of any /// compression in use on the source. If CompressionType is not specified, this routine determines the compression type automatically. /// /// /// The SetupDecompressOrCopyFile function returns a system error code that indicates the outcome of the operation. /// To get extended error information, call GetLastError. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdecompressorcopyfilea WINSETUPAPI DWORD // SetupDecompressOrCopyFileA( PCSTR SourceFileName, PCSTR TargetFileName, PUINT CompressionType ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDecompressOrCopyFileA")] public static extern uint SetupDecompressOrCopyFile([MarshalAs(UnmanagedType.LPTStr)] string SourceFileName, [MarshalAs(UnmanagedType.LPTStr)] string TargetFileName, [In] IntPtr CompressionType = default); /// /// /// [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 SetupDefaultQueueCallback function is the default queue callback routine included with the Setup API. You can use it /// to process notifications sent by the SetupCommitFileQueue function. /// /// /// /// Pointer to the context initialized by the SetupInitDefaultQueueCallback or SetupInitDefaultQueueCallbackEx functions. /// /// /// Notification of a queue action. This parameter can be one of the values shown in the following table. /// /// /// Value /// Meaning /// /// /// SPFILENOTIFY_STARTQUEUE /// Started queued file operations. /// /// /// SPFILENOTIFY_ENDQUEUE /// Finished queued file operations. /// /// /// SPFILENOTIFY_STARTSUBQUEUE /// Started a copy, rename, or delete subqueue. /// /// /// SPFILENOTIFY_ENDSUBQUEUE /// Finished a copy, rename, or delete subqueue. /// /// /// SPFILENOTIFY_STARTRENAME /// Started a rename operation. /// /// /// SPFILENOTIFY_ENDRENAME /// Finished a rename operation. /// /// /// SPFILENOTIFY_RENAMEERROR /// Encountered an error while renaming a file. /// /// /// SPFILENOTIFY_STARTDELETE /// Started a delete operation. /// /// /// SPFILENOTIFY_ENDDELETE /// Finished a delete operation. /// /// /// SPFILENOTIFY_DELETEERROR /// Encountered an error while deleting a file. /// /// /// SPFILENOTIFY_STARTCOPY /// Started a copy operation. /// /// /// SPFILENOTIFY_ENDCOPY /// Finished a copy operation. /// /// /// SPFILENOTIFY_COPYERROR /// Encountered an error while copying a file. /// /// /// SPFILENOTIFY_NEEDMEDIA /// New media is required. /// /// /// SPFILENOTIFY_LANGMISMATCH /// Existing target file is in a different language than the source. /// /// /// SPFILENOTIFY_TARGETEXISTS /// Target file exists. /// /// /// SPFILENOTIFY_TARGETNEWER /// Existing target file is newer than source. /// /// /// /// /// Additional message information. The content of this parameter depends on the value of the Notification parameter. /// /// /// Additional message information. The content of this parameter depends on the value of the Notification parameter. /// /// /// Returns an unsigned integer to SetupCommitFileQueue that can be the one of the values shown in the following table. /// /// /// Return code /// Description /// /// /// FILEOP_ABORT /// Aborts the operation. /// /// /// FILEOP_DOIT /// Performs the file operation. /// /// /// FILEOP_SKIP /// Skips the operation. /// /// /// FILEOP_RETRY /// Retries the operation. /// /// /// FILEOP_NEWPATH /// Gets a new path for the operation. /// /// /// To get extended error information, call GetLastError. /// /// /// /// The SetupDefaultQueueCallback function is usually only called explicitly by a custom queue callback routine. The custom /// callback handles a subset of the queue commit notifications and calls the SetupDefaultQueueCallback function to handle /// the rest of the notifications. /// /// For more information see, Queue Notifications. /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupdefaultqueuecallbacka WINSETUPAPI UINT // SetupDefaultQueueCallbackA( PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2 ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDefaultQueueCallbackA")] public static extern FILEOP_RESULT SetupDefaultQueueCallback([In] IntPtr Context, SPFILENOTIFY Notification, [In] IntPtr Param1, [In] IntPtr Param2); /// /// /// [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 SetupDeleteError function generates a dialog box that informs the user of a delete error. /// /// Handle to the parent window for this dialog box. /// /// Optional pointer to a null-terminated string specifying the error dialog box title. If this parameter is NULL, the /// default title of "Delete Error" (localized) is used. /// /// /// Pointer to a null-terminated string specifying the full path of the file on which the delete operation failed. /// /// The system error code encountered during the file operation. /// /// Flags that control 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 to get the user's attention 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 SetupDeleteError 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-setupdeleteerrora WINSETUPAPI UINT SetupDeleteErrorA( // HWND hwndParent, PCSTR DialogTitle, PCSTR File, UINT Win32ErrorCode, DWORD Style ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDeleteErrorA")] public static extern uint SetupDeleteError(HWND hwndParent, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? DialogTitle, [MarshalAs(UnmanagedType.LPTStr)] string File, 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 SetupDestroyDiskSpaceList function destroys a disk-space list and releases the resources allocated to it. /// /// Handle to the disk-space list to be deconstructed. /// /// 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-setupdestroydiskspacelist WINSETUPAPI BOOL // SetupDestroyDiskSpaceList( HDSKSPC DiskSpace ); [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDestroyDiskSpaceList")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupDestroyDiskSpaceList(HDSKSPC DiskSpace); /// /// /// [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 SetupDuplicateDiskSpaceList function duplicates a disk-space list as a new independent disk-space list. /// /// Handle to the disk-space list to be duplicated. /// Unused, must be zero. /// Unused, must be zero. /// Unused, must be zero. /// /// If the function succeeds, it returns a handle to the new disk-space list. /// If the function fails, it returns null. To get extended error information, call GetLastError. /// /// /// Note /// /// The setupapi.h header defines SetupDuplicateDiskSpaceList 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-setupduplicatediskspacelista WINSETUPAPI HDSKSPC // SetupDuplicateDiskSpaceListA( HDSKSPC DiskSpace, PVOID Reserved1, DWORD Reserved2, UINT Flags ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupDuplicateDiskSpaceListA")] public static extern SafeHDSKSPC SetupDuplicateDiskSpaceList(HDSKSPC DiskSpace, IntPtr Reserved1 = default, uint Reserved2 = default, uint Flags = default); /// /// /// [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 SetupEnumInfSections function retrieves section names from an INF file. /// /// Handle to the INF file that is to be queried. /// /// The zero-based index of the section name to retrieve. This index may not correspond to the order of sections as they appear in /// the INF file. /// /// /// Pointer to a buffer that receives the section name. 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 name. Using this technique, you can avoid errors /// caused by an insufficient buffer size. This parameter is optional. For more information, see the Remarks section. /// /// /// Size of the buffer pointed to by ReturnBuffer in characters. This number includes the terminating NULL character. /// /// /// Pointer to a location that receives the required size of the buffer pointed to by ReturnBuffer. The size is specified as the /// number of characters required to store the section name, including the terminating NULL character. /// /// /// If the function succeeds, the return value is TRUE. /// If the function fails, the return value is FALSE. To get extended error information, call GetLastError. /// /// GetLastError returns ERROR_NO_MORE_ITEMS if the value of EnumerationIndex is greater than or equal to the number /// of sections names in the INF file. /// /// /// /// /// This function can enumerate all unique section names in the INF file. If a section name appears more than once in an INF file, /// the function returns the name only once using a single enumeration index. To return all section names in the INF file, call the /// function beginning with an enumeration index of zero and then make repeated calls to the function while incrementing the index /// until the function returns FALSE and GetLastError returns ERROR_NO_MORE_ITEMS. Your application should not rely on /// the section names being returned in any order based on the enumeration index. /// /// /// Note /// /// The setupapi.h header defines SetupEnumInfSections 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-setupenuminfsectionsa WINSETUPAPI BOOL // SetupEnumInfSectionsA( HINF InfHandle, UINT Index, PSTR Buffer, UINT Size, UINT *SizeNeeded ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupEnumInfSectionsA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupEnumInfSections(HINF InfHandle, uint Index, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder? Buffer, uint Size, out uint SizeNeeded); /// /// /// [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 SetupFindFirstLine function locates a line in the specified section of an INF file. If the Key parameter is /// NULL, SetupFindFirstLine returns the first line of the section. /// /// /// Handle to the INF file to query. /// Pointer to a null-terminated string specifying the section of the INF files to search in. /// /// Optional pointer to a null-terminated string specifying the key to search for within the section. The /// null-terminated string should not exceed the size of the destination buffer. This parameter can be NULL. If Key is /// NULL, the first line in the section is returned. /// /// /// Pointer to a structure that receives the context information used internally by the INF handle. Applications must not overwrite /// values in this structure. /// /// If the function could not find a line, the return value is zero. To get extended error information, call GetLastError. /// /// /// If the InfHandle parameter references multiple INF files that have been appended together using SetupOpenAppendInfFile, the /// SetupFindFirstLine function searches across the specified section in all of the files referenced by the specified HINF. /// /// /// Note /// /// The setupapi.h header defines SetupFindFirstLine 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-setupfindfirstlinea WINSETUPAPI BOOL SetupFindFirstLineA( // HINF InfHandle, PCSTR Section, PCSTR Key, PINFCONTEXT Context ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupFindFirstLineA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupFindFirstLine(HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string Section, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? Key, out INFCONTEXT 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 SetupFindNextLine returns the location of the next line in an INF file section relative to ContextIn.Line. /// /// Pointer to the INF file context retrieved by a call to the SetupFindFirstLine function. /// /// Pointer to a variable in which this function returns the context of the found line. ContextOut can point to ContextIn if the /// caller wishes. /// /// /// If this function finds the next line, the return value is a nonzero value. Otherwise, the return value is zero. To get extended /// error information, call GetLastError. /// /// /// If ContextIn.Line references multiple INF files that have been appended together using SetupOpenAppendInfFile, this function /// searches across the specified section in all files referenced by the HINF to locate the next line. /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupfindnextline WINSETUPAPI BOOL SetupFindNextLine( // PINFCONTEXT ContextIn, PINFCONTEXT ContextOut ); [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupFindNextLine")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupFindNextLine(in INFCONTEXT ContextIn, out INFCONTEXT ContextOut); /// /// /// [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 SetupFindNextMatchLine function returns the location of the next line in an INF file relative to ContextIn.Line that /// matches a specified key. /// /// /// Pointer to an INF file context, as retrieved by a call to the SetupFindFirstLine function. /// /// If this optional parameter is specified, it supplies a key to match. This parameter should be a null-terminated string. This /// parameter can be Null. If Key is not specified, the SetupFindNextMatchLine function is equivalent to the /// SetupFindNextLine function. /// /// /// Pointer to a variable in which this function returns the context of the found line. ContextOut can point to ContextIn if the /// caller wishes. /// /// /// The function returns a nonzero value if it finds a matching line. Otherwise, the return value is zero. To get extended error /// information, call GetLastError. /// /// /// /// If ContextIn.Inf references multiple INF files that have been appended together using SetupOpenAppendInfFile, the /// SetupFindNextMatchLine function searches across the specified section in all files referenced by the HINF to locate the /// next matching line. /// /// /// Note /// /// The setupapi.h header defines SetupFindNextMatchLine 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-setupfindnextmatchlinea WINSETUPAPI BOOL // SetupFindNextMatchLineA( PINFCONTEXT ContextIn, PCSTR Key, PINFCONTEXT ContextOut ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupFindNextMatchLineA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupFindNextMatchLine(in INFCONTEXT ContextIn, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? Key, out INFCONTEXT ContextOut); /// /// /// [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 SetupFreeSourceList function frees the system resources allocated to a source list. /// /// /// Pointer to an array of sources from SetupQuerySourceList. The null-terminated string should not exceed the size of the /// destination buffer. When the function returns, this pointer is set to NULL. /// /// 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 SetupFreeSourceList 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-setupfreesourcelista WINSETUPAPI BOOL // SetupFreeSourceListA( PCSTR **List, UINT Count ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupFreeSourceListA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupFreeSourceList(IntPtr List, 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 SetupGetBinaryField function retrieves binary data from a line in an INF file section, from the specified field to /// the end of the line. /// /// /// INF context for the line. /// /// The 1-based index of the starting field within the specified line from which the binary data should be retrieved. The binary /// data is built from each field, starting at this point to the end of the line. Each field corresponds to 1 byte and is in /// hexadecimal notation. A FieldIndex of zero is not valid with this function. /// /// /// Optional pointer to a buffer that receives the binary data. You should ensure the destination buffer is the same size or larger /// than the source 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 ReturnBuffer, in characters. This number includes the null terminator. /// /// /// Optional pointer to a variable that receives the required size for the buffer pointed to ReturnBuffer, in characters. This /// number includes the null terminator. If the size needed 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. /// /// GetLastError returns ERROR_INVALID_DATA if a field that SetupGetBinaryField retrieves is not a valid hexadecimal number /// in the range 0-FF. /// /// /// /// /// 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. /// /// To better understand how this function works, consider the following line from an INF file. /// /// X=34,FF,00,13 /// /// /// If SetupGetBinaryField was called on the preceding line, the binary values 34, FF, 00, and 13 would be put into the /// buffer specified by ReturnBuffer. /// /// /// For the Unicode version of this function, the buffer sizes ReturnBufferSize and RequiredSize are specified in number of /// characters. This number includes the null terminator. For the ANSI version of this function, the sizes are specified in /// number of bytes. /// /// /// 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. /// /// /// Thus, 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. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupgetbinaryfield WINSETUPAPI BOOL SetupGetBinaryField( // PINFCONTEXT Context, DWORD FieldIndex, PBYTE ReturnBuffer, DWORD ReturnBufferSize, LPDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetBinaryField")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetBinaryField(in INFCONTEXT Context, uint FieldIndex, [Out, Optional] IntPtr 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 SetupGetFieldCount function retrieves the number of fields in the specified line in an INF file. /// /// Pointer to the context for a line in an INF file. /// /// This function returns the number of fields on the line. If Context is invalid, 0 is returned. To get extended error information, /// call GetLastError. /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupgetfieldcount WINSETUPAPI DWORD SetupGetFieldCount( // PINFCONTEXT Context ); [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetFieldCount")] public static extern uint SetupGetFieldCount(in INFCONTEXT 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 SetupGetFileCompressionInfo function examines a physical file to determine if it is compressed and gets its full /// path, size, and the size of the uncompressed target file. /// /// /// Note that this function is obsolete and has been replaced by SetupGetFileCompressionInfoEx. Do not use /// SetupGetFileCompressionInfo, instead always use SetupGetFileCompressionInfoEx. /// /// /// /// File name of the file about which information is required. If the file is not found on the source media exactly as named, the /// file is searched for with up to two alternate "compressed-form" names. For example, if the file is F:\x86\cmd.exe and it is not /// found, F:\mpis\cmd.ex_ is searched for and, if that is not found, a search is done for F:\x86\cmd.ex$. You should use a /// null-terminated string. /// /// /// Pointer to a variable that receives the full path of the file that it has been able to locate. The caller can free the pointer /// with a call to LocalFree. The path is valid only if the function returns NO_ERROR. Note that if the version of /// SetupAPI.dll is less than 5.0.2195, then the caller needs to use the exported function MyFree from SetupAPI to free the /// memory allocated by this function, rather then using LocalFree. See the Remarks section. /// /// /// Pointer to a variable in which this function returns the size of the file in its current form which is the current size of the /// file named by ActualSourceFileName. The size is determined by examining the source file; it is not retrieved from an INF file. /// The source file size is valid only if the function returns NO_ERROR. /// /// /// Pointer to a variable in which this function returns the size the file will occupy when it is uncompressed or copied. If the /// file is not compressed, this value will be the same as SourceFileSize. The size is determined by examining the file; it is not /// retrieved from an INF file. The target file size is valid only if the function returns NO_ERROR. /// /// /// /// Pointer to a variable in which this function returns a value indicating the type of compression used on ActualSourceFileName. /// The compression type is valid only if the function returns NO_ERROR. The value can be one of the following flags. /// /// FILE_COMPRESSION_NONE /// The source file is not compressed with a recognized compression algorithm. /// FILE_COMPRESSION_WINLZA /// The source file is compressed with LZ compression. /// FILE_COMPRESSION_MSZIP /// The source file is compressed with MSZIP compression. /// /// /// /// The function returns a system error code that indicates the outcome of the file search. The error code can be one of the /// following values. /// /// To get extended error information, call GetLastError. /// /// /// Do not use SetupGetFileCompressionInfo, instead always use SetupGetFileCompressionInfoEx. /// /// Because SetupGetFileCompressionInfo determines the compression by referencing the physical file, your setup application /// should ensure that the file is present before calling SetupGetFileCompressionInfo. /// /// /// Note that if the version of SetupAPI.dll is less than 5.0.2195, then the caller needs to use the exported function MyFree /// from SetupAPI to free the memory allocated by this function, rather then using LocalFree. If the call to LocalFree /// causes an Access Violation, you should solve the problem by using MyFree. /// /// The following is an example of how to obtain the MyFree function from the SetupAPI.dll: /// /// typedef VOID (WINAPI* MYFREEFUNC)(LPVOID lpBuff); /// MYFREEFUNC MyFree; /// HMODULE hDll=NULL; /// hDll = GetModuleHandle("SETUPAPI.DLL"); /// MyFree = (MYFREEFUNC)GetProcAddress(hDll, "MyFree"); /// ... /// other code here to prepare file queue /// ... /// PTSTR lpActualSourceFileName; /// SetupGetFileCompressionInfo(...,&lpActualSourceFileName,...,...,...); /// ... /// MyFree(lpActualSourceFileName); /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupgetfilecompressioninfoa WINSETUPAPI DWORD // SetupGetFileCompressionInfoA( PCSTR SourceFileName, PSTR *ActualSourceFileName, PDWORD SourceFileSize, PDWORD TargetFileSize, // PUINT CompressionType ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetFileCompressionInfoA")] public static extern uint SetupGetFileCompressionInfo([MarshalAs(UnmanagedType.LPTStr)] string SourceFileName, [MarshalAs(UnmanagedType.LPTStr)] out string ActualSourceFileName, out uint SourceFileSize, out uint TargetFileSize, out FILE_COMPRESSION CompressionType); /// /// /// [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 SetupGetFileCompressionInfoEx function examines a potentially compressed file and gets the type of compression, the /// file's full path (including file name), the compressed size, and the size of the uncompressed target file. The caller of the /// function passes in the name of the file to be examined and pointers to locations for the buffer and buffer size to receive the /// returned file name and path. /// /// /// To determine the size of the buffer for the returned path and file name, you can call SetupGetFileCompressionInfoEx with /// ActualSourceFileNameBuffer specified Null and ActualSourceFileNameLen containing 0. The function succeeds and on return /// fills in RequiredBufferLen. /// /// /// /// File name of the potentially compressed file to be examined. If the file is not found on the source media exactly as named, /// Setup searches for up to two alternate names. For example; if Setup does not find F:\x86\cmd.exe, it searches for /// F:\mpis\cmd.ex_ and if that name is not found, it searches for F:\x86\cmd.ex$. /// /// /// Pointer to a buffer that receives the actual file name and path if this parameter is not NULL. This is valid only if the /// function returns NO_ERROR. /// /// /// Size of the buffer specified by ActualSourceFileNameBuffer, in characters. You would typically use a buffer size of MAX_PATH. If /// ActualSourceFileNameLen is too small, the function fails with ERROR_INSUFFICIENT_BUFFER. ActualSourceFileNameLen must contain /// zero if ActualSourceFileNameBuffer is NULL. /// /// /// Size of the file name and full path including the terminating NULL, if this parameter is not NULL. If /// ActualSourceFileNameBuffer is NULL and ActualSourceFileNameLen is zero, the function succeeds but fills in /// RequiredBufferLen. This parameter is valid only if the function returns NO_ERROR or ERROR_INSUFFICIENT_BUFFER. /// /// /// Pointer to a variable in which this function returns the size of the file in its current form, which is the current size of the /// file named by ActualSourceFileNameBuffer. The size is determined by examining the source file; it is not retrieved from an INF /// file. The source file size is valid only if the function returns NO_ERROR or ERROR_INSUFFICIENT_BUFFER. /// /// /// Pointer to a variable in which this function returns the size that the file will occupy when it is uncompressed or copied. If /// the file is not compressed, this value will be the same as SourceFileSize. The size is determined by examining the file; it is /// not retrieved from an INF file. The target file size is valid only if the function returns NO_ERROR or ERROR_INSUFFICIENT_BUFFER. /// /// /// /// Pointer to a variable in which this function returns a value indicating the type of compression used on ActualSourceFileName. /// The compression type is valid only if the function returns NO_ERROR or ERROR_INSUFFICIENT_BUFFER. This parameter value can be /// one of the following flags. /// /// FILE_COMPRESSION_NONE /// The source file is not compressed with a recognized compression algorithm. /// FILE_COMPRESSION_WINLZA /// The source file is compressed with LZ compression. /// FILE_COMPRESSION_MSZIP /// The source file is compressed with MSZIP compression. /// /// /// If the function succeeds, the return value is TRUE (nonzero). /// /// If the function fails, the return value is FALSE (zero). The function can also return one of the following system error codes. /// /// To get extended error information, call GetLastError. /// /// /// /// Because SetupGetFileCompressionInfoEx determines the compression by examining the physical file, your setup application /// should ensure that the file is present before calling SetupGetFileCompressionInfoEx. /// /// /// Note /// /// The setupapi.h header defines SetupGetFileCompressionInfoEx 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-setupgetfilecompressioninfoexa WINSETUPAPI BOOL // SetupGetFileCompressionInfoExA( PCSTR SourceFileName, PSTR ActualSourceFileNameBuffer, DWORD ActualSourceFileNameBufferLen, // PDWORD RequiredBufferLen, PDWORD SourceFileSize, PDWORD TargetFileSize, PUINT CompressionType ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetFileCompressionInfoExA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetFileCompressionInfoEx([MarshalAs(UnmanagedType.LPTStr)] string SourceFileName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? ActualSourceFileNameBuffer, uint ActualSourceFileNameBufferLen, out uint RequiredBufferLen, out uint SourceFileSize, out uint TargetFileSize, out uint CompressionType); /// /// /// [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 SetupGetFileQueueCount function gets the count from a setup file queue. /// /// Handle to an open setup file queue. /// /// Flag that specifies which subqueue count to be returned. /// /// /// Flag /// Meaning /// /// /// FILEOP_COPY /// Return the number of entries in the copy subqueue. /// /// /// FILEOP_RENAME /// Return the number of entries in the rename subqueue. /// /// /// FILEOP_DELETE /// Return the number of entries in the delete subqueue. /// /// /// FILEOP_BACKUP /// Return the number of entries in the backup subqueue. /// /// /// /// Count from the setup file queue. /// /// 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-setupgetfilequeuecount WINSETUPAPI BOOL // SetupGetFileQueueCount( HSPFILEQ FileQueue, UINT SubQueueFileOp, PUINT NumOperations ); [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetFileQueueCount")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetFileQueueCount(HSPFILEQ FileQueue, FILEOP SubQueueFileOp, out uint NumOperations); /// /// /// [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 SetupGetFileQueueFlags function gets the flags from a setup file queue. /// /// Handle to an open setup file queue. /// /// Pointer to location that contains the flag set 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-setupgetfilequeueflags WINSETUPAPI BOOL // SetupGetFileQueueFlags( HSPFILEQ FileQueue, PDWORD Flags ); [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetFileQueueFlags")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetFileQueueFlags(HSPFILEQ FileQueue, out SPQ_FLAG Flags); /// /// The SetupGetInfDriverStoreLocation function retrieves the fully qualified file name (directory path and file name) of an /// INF file in the driver store that corresponds to a specified INF file in the system INF file directory or a specified INF file /// in the driver store. /// /// /// /// A pointer to a NULL-terminated string that contains the name, and optionally the full directory path, of an INF file in the /// system INF file directory. Alternatively, this parameter is a pointer to a NULL-terminated string that contains the fully /// qualified file name (directory path and file name) of an INF file in the driver store. /// /// For more information about how to specify the INF file, see the following Remarks section. /// /// Reserved for system use. /// Reserved for system use. /// /// A pointer to a buffer in which the function returns a NULL-terminated string that contains the fully qualified file name of the /// specified INF file. This parameter can be set to NULL. The maximum supported path size is MAX_PATH. For information about /// how to determine the required size of the buffer, see the following Remarks section. /// /// The size, in characters, of the buffer supplied by ReturnBuffer. /// /// A pointer to a DWORD-typed variable that receives the size, in characters, of the ReturnBuffer buffer. This parameter is /// optional and can be set to NULL. /// /// /// /// If SetupGetInfDriverStoreLocation succeeds, the function returns TRUE; otherwise, the function returns /// FALSE. To obtain extended error information, call GetLastError. /// /// /// If the size, in characters, of the fully qualified file name of the requested INF file, including a null-terminator, is greater /// than ReturnBufferSize, the function will fail, and a call to GetLastError will return ERROR_INSUFFICIENT_BUFFER. /// /// /// /// /// To determine the size of the return buffer that is required to contain the fully qualified file name of the specified INF file /// in the driver store, call SetupGetInfDriverStoreLocation and set ReturnBuffer to NULL, ReturnBufferSize to zero, /// and supply RequiredSize. SetupGetInfDriverStoreLocation will return the required buffer size in RequiredSize. /// /// /// When device installation preinstalls a driver package in the driver store, it creates two copies of the driver package INF file. /// Device installation installs one copy in the system INF directory and assigns that copy of the INF file a unique published file /// name of the form OEMnnn.inf. Device installation installs a second copy of the INF file in the driver store and assigns that /// copy the original INF file name. /// /// /// SetupGetInfDriverStoreLocation returns the fully qualified file name of the INF file in the driver store that matches the /// INF file, if any, that is supplied by FileName. Filename must specify the file name, and optionally the directory path, of an /// INF file in the system INF directory. Alternatively, Filename must specify the fully qualified file name of an INF file in the /// driver store. /// /// /// For example, assume that the INF file for a driver package is Myinf.inf, and that for this driver package, device installation /// installs the INF file OEM1.inf in the system INF directory C:\Windows\inf. Further assume that device installation installs the /// corresponding INF file copy C:\windows\system32\driverstore\filerepository\myinf_12345678\myinf.inf in the driver store. In this /// case, the function returns C:\windows\system32\driverstore\filerepository\myinf_12345678\myinf.inf if FileName supplies one of /// the following strings: OEM1.inf, C:\Windows\inf\OEM1.inf, or C:\windows\system32\driverstore\filerepository\myinf_12345678\myinf.inf. /// /// /// Class installers and co-installers can use SetupGetInfDriverStoreLocation to access files in a driver package that is /// preinstalled in the driver store. To determine the path of the driver package in the driver store, the installer does the following: /// /// /// /// /// Call SetupDiGetDriverInfoDetail to retrieve a SP_DRVINFO_DETAIL_DATA structure for a driver. The InfFileName member of /// this structure contains the fully qualified file name of the driver INF file in the system INF directory. /// /// /// /// /// Call SetupGetInfDriverStoreLocation and supply the fully qualified file name of the driver INF file that was retrieved by /// calling SetupDiGetDriverInfoDetail. SetupGetInfDriverStoreLocation will return the fully qualified file name of /// the driver INF file in the driver store. The directory path part of the fully qualified file name of the INF file is the path of /// the driver package files. /// /// /// /// /// NoteSetupGetInfDriverStoreLocation does not process the contents of the INF file that is specified in FileName. /// You cannot use this function to perform a content-specific search for an INF file in the driver store. /// /// /// Call the SetupGetInfPublishedName function to retrieve the fully qualified file name of an INF file in the system INF file /// directory that corresponds to a specified INF file in the system INF file directory or a specified file in the driver store. /// /// /// Note /// /// The setupapi.h header defines SetupGetInfDriverStoreLocation 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-setupgetinfdriverstorelocationa WINSETUPAPI BOOL // SetupGetInfDriverStoreLocationA( PCSTR FileName, PSP_ALTPLATFORM_INFO AlternatePlatformInfo, PCSTR LocaleName, PSTR ReturnBuffer, // DWORD ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetInfDriverStoreLocationA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetInfDriverStoreLocation([MarshalAs(UnmanagedType.LPTStr)] string FileName, [In, Optional] IntPtr AlternatePlatformInfo, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? LocaleName, [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 SetupGetInfFileList function returns a list of INF files located in a caller-specified directory to a call-supplied buffer. /// /// /// /// Optional pointer to a null-terminated string containing the path of the directory in which to search. If this value is /// NULL, the %windir%\inf directory is used. /// /// /// Type of INF file to search for. May be a combination of the following flags. /// INF_STYLE_OLDNT /// A legacy INF file format. /// INF_STYLE_WIN4 /// A Windows INF file format. /// /// /// If not NULL, points to a buffer in which this function returns the list of all INF files of the desired styles that were /// found in the specified subdirectory. File names are null-terminated, with an extra null at the end of the list. /// 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. The filenames do not include the path. See the Remarks section. /// /// /// Size of the buffer pointed to by the ReturnBuffer parameter, in characters. This includes the null terminator. If /// ReturnBuffer is not specified, ReturnBufferSize is ignored. /// /// /// If not NULL, points to a variable in which this function returns the required size for the buffer pointed to by the /// ReturnBuffer parameter, in characters. This includes the null terminator. If ReturnBuffer is specified and the size /// needed 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. /// /// /// If multiple INF file styles are returned by this function, the style of a particular INF file can be determined by calling the /// SetupGetInfInformation function /// /// /// Note /// /// The setupapi.h header defines SetupGetInfFileList 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-setupgetinffilelista WINSETUPAPI BOOL // SetupGetInfFileListA( PCSTR DirectoryPath, DWORD InfStyle, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetInfFileListA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetInfFileList([Optional, MarshalAs(UnmanagedType.LPTStr)] string? DirectoryPath, INF_STYLE InfStyle, [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 SetUpGetInfInformation function returns the SP_INF_INFORMATION structure for the specified INF file to a buffer. /// /// Handle or a file name for an INF file, depending on the value of SearchControl. /// /// This parameter can be one of the following constants. /// INFINFO_INF_SPEC_IS_HINF /// /// InfSpec is an INF handle. A single INF handle may reference multiple INF files if they have been append-loaded together. If it /// does, the structure returned by this function contains multiple sets of information. /// /// INFINFO_INF_NAME_IS_ABSOLUTE /// The string specified for InfSpec is a full path. No further processing is performed on InfSpec. /// INFINFO_DEFAULT_SEARCH /// /// Search the default locations for the INF file specified for InfSpec, which is assumed to be a filename only. The default /// locations are %windir%\inf, followed by %windir%\system32. /// /// INFINFO_REVERSE_DEFAULT_SEARCH /// Same as INFINFO_DEFAULT_SEARCH, except the default locations are searched in reverse order. /// INFINFO_INF_PATH_LIST_SEARCH /// Search for the INF in each of the directories listed in the DevicePath value entry under the following: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion /// /// /// If not NULL, points to a buffer in which this function returns the structure. /// /// You can call the function one time 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. For more /// information, see the Remarks section of this topic. /// /// /// Size of ReturnBuffer, in bytes. /// /// /// If not NULL, points to a variable in which this function returns the required size, in bytes, for the buffer pointed to /// by ReturnBuffer. /// /// /// If ReturnBuffer is specified and the size needed 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 0 (zero). To get extended error information, call GetLastError. /// If the INF file cannot be located, the function returns FALSE and a subsequent call to GetLastError returns ERROR_FILE_NOT_FOUND. /// /// /// /// If this function is called with a ReturnBuffer of NULL and a ReturnBufferSize of 0 (zero), the function puts the buffer /// size needed to hold the specified data into the variable pointed to by RequiredSize. If the function succeeds, the return value /// is a nonzero value. Otherwise, the return value is 0 (zero), and extended error information can be obtained by calling GetLastError. /// /// /// Note /// /// The setupapi.h header defines SetupGetInfInformation 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-setupgetinfinformationa WINSETUPAPI BOOL // SetupGetInfInformationA( LPCVOID InfSpec, DWORD SearchControl, PSP_INF_INFORMATION ReturnBuffer, DWORD ReturnBufferSize, PDWORD // RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetInfInformationA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetInfInformation(HFILE InfSpec, INFINFO SearchControl, [Out, Optional] IntPtr 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 SetUpGetInfInformation function returns the SP_INF_INFORMATION structure for the specified INF file to a buffer. /// /// Handle or a file name for an INF file, depending on the value of SearchControl. /// /// This parameter can be one of the following constants. /// INFINFO_INF_SPEC_IS_HINF /// /// InfSpec is an INF handle. A single INF handle may reference multiple INF files if they have been append-loaded together. If it /// does, the structure returned by this function contains multiple sets of information. /// /// INFINFO_INF_NAME_IS_ABSOLUTE /// The string specified for InfSpec is a full path. No further processing is performed on InfSpec. /// INFINFO_DEFAULT_SEARCH /// /// Search the default locations for the INF file specified for InfSpec, which is assumed to be a filename only. The default /// locations are %windir%\inf, followed by %windir%\system32. /// /// INFINFO_REVERSE_DEFAULT_SEARCH /// Same as INFINFO_DEFAULT_SEARCH, except the default locations are searched in reverse order. /// INFINFO_INF_PATH_LIST_SEARCH /// Search for the INF in each of the directories listed in the DevicePath value entry under the following: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion /// /// /// If not NULL, points to a buffer in which this function returns the structure. /// /// You can call the function one time 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. For more /// information, see the Remarks section of this topic. /// /// /// Size of ReturnBuffer, in bytes. /// /// /// If not NULL, points to a variable in which this function returns the required size, in bytes, for the buffer pointed to /// by ReturnBuffer. /// /// /// If ReturnBuffer is specified and the size needed 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 0 (zero). To get extended error information, call GetLastError. /// If the INF file cannot be located, the function returns FALSE and a subsequent call to GetLastError returns ERROR_FILE_NOT_FOUND. /// /// /// /// If this function is called with a ReturnBuffer of NULL and a ReturnBufferSize of 0 (zero), the function puts the buffer /// size needed to hold the specified data into the variable pointed to by RequiredSize. If the function succeeds, the return value /// is a nonzero value. Otherwise, the return value is 0 (zero), and extended error information can be obtained by calling GetLastError. /// /// /// Note /// /// The setupapi.h header defines SetupGetInfInformation 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-setupgetinfinformationa WINSETUPAPI BOOL // SetupGetInfInformationA( LPCVOID InfSpec, DWORD SearchControl, PSP_INF_INFORMATION ReturnBuffer, DWORD ReturnBufferSize, PDWORD // RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetInfInformationA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetInfInformation([MarshalAs(UnmanagedType.LPTStr)] string InfSpec, INFINFO SearchControl, [Out, Optional] IntPtr ReturnBuffer, uint ReturnBufferSize, out uint RequiredSize); /// /// The SetupGetInfPublishedName function retrieves the fully qualified file name (directory path and file name) of an INF /// file in the system INF file directory that corresponds to a specified INF file in the driver store or a specified INF file in /// the system INF file directory. /// /// /// A pointer to a NULL-terminated string that contains the fully qualified file name (directory path and file name) of an INF file /// in the driver store. Alternatively, this parameter is a pointer to a NULL-terminated string that contains the name, and /// optionally the full directory path, of an INF file in the system INF file directory. For more information about how to specify /// the INF file, see the following Remarks section. /// /// /// A pointer to the buffer in which SetupGetInfPublishedName returns a NULL-terminated string that contains the fully /// qualified file name of the specified INF file in the system INF directory. The maximum path size is MAX_PATH. This pointer can /// be set to NULL. For information about how to determine the required size of the return buffer, see the following /// Remarks section. /// /// The size, in characters, of the buffer supplied by ReturnBuffer. /// /// A pointer to a DWORD-typed variable that receives the size, in characters, of the ReturnBuffer buffer. This parameter is /// optional and can be set to NULL. /// /// /// /// If SetupGetInfPublishedName succeeds, the function returns TRUE; otherwise, the function returns FALSE. To /// obtain extended error information, call GetLastError. /// /// /// If the size, in characters, of the fully qualified file name of the requested INF file, including a null-terminator, is greater /// than ReturnBufferSize, the function will fail, and a call to GetLastError will return ERROR_INSUFFICIENT_BUFFER. /// /// /// /// /// To determine the size of the return buffer that is required to contain the fully qualified file name of the specified INF file /// in the system INF directory, call SetupGetInfPublishedName and set ReturnBuffer to NULL, ReturnBufferSize to zero, /// and supply RequiredSize. SetupGetInfPublishedName will return the required buffer size in RequiredSize. /// /// /// When device installation preinstalls a driver package in the driver store, it creates two copies of the driver package INF file. /// Device installation adds one copy to the system INF directory and assigns that copy of the INF file a unique published file name /// of the form OEMnnn.inf. Device installation adds a second copy of the INF file to the driver store and assigns that copy the /// original INF file name. /// /// /// SetupGetInfPublishedName returns the fully qualified file name of the INF file in the system INF file directory that /// matches the INF file, if any, that is supplied by DriverStoreLocation. DriverStoreLocation must specify the fully qualified file /// name of an INF file in the driver store or must specify the file name, and optionally the directory path, of an INF file in the /// system INF directory. For example, assume that the INF file for a driver package is myinf.inf, and that for this driver package, /// device installation installs the INF file OEM1.inf in the system INF directory C:\Windows\inf. Further assume that device /// installation installs the corresponding INF file copy C:\windows\system32\driverstore\filerepository\myinf_12345678\myinf.inf in /// the driver store. In this case, the function returns C:\Windows\inf\OEM1.inf if DriverStoreLocation supplies one of the /// following strings: C:\windows\system32\driverstore\filerepository\myinf_12345678\myinf.inf, OEM1.inf, or C:\Windows\inf\OEM1.inf. /// /// /// Call the SetupGetInfDriverStoreLocation function to retrieve the fully qualified file name of an INF file in the driver store /// that corresponds to a specified INF file in the system INF file directory or a specified file in the driver store. /// /// /// Note /// /// The setupapi.h header defines SetupGetInfPublishedName 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-setupgetinfpublishednamea WINSETUPAPI BOOL // SetupGetInfPublishedNameA( PCSTR DriverStoreLocation, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetInfPublishedNameA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetInfPublishedName([MarshalAs(UnmanagedType.LPTStr)] string DriverStoreLocation, [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 SetupGetIntField function retrieves an integer value from the specified field of a line in an INF file. /// /// Pointer to the context for a line in an INF file. /// /// The 1-based index of the field within the specified line from which the integer should be retrieved. /// /// A FieldIndex of 0 can be used to retrieve an integer key (For example, consider the following INF line, 431 = 1, 2, 4. The value /// 431 would be put into the variable pointed at by IntegerValue if SetupGetIntField was called with a FieldIndex of 0). /// /// /// /// Pointer to a variable that receives the integer. If the field is not an integer, the function fails and a call to GetLastError /// returns ERROR_INVALID_DATA. /// /// /// 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 integer field may start with a positive (+) or negative (-) sign. It will be interpreted as a decimal number, unless /// prefixed in the file with 0x or 0X, in which case it is hexadecimal. /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupgetintfield WINSETUPAPI BOOL SetupGetIntField( // PINFCONTEXT Context, DWORD FieldIndex, PINT IntegerValue ); [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetIntField")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetIntField(in INFCONTEXT Context, uint FieldIndex, out int IntegerValue); /// /// /// [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 SetupGetLineByIndex function locates a line by its index value in the specified section in the INF file. /// /// Handle to the INF file. /// Pointer to a null-terminated string specifying the section of the INF file to search. /// /// Index of the line to be located. The total number of lines in a particular section can be found with a call to SetupGetLineCount. /// /// Pointer to a variable that receives the context information for the found line. /// /// 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 InfHandle references multiple INF files that have been appended together using SetupOpenAppendInfFile, this function searches /// across the specified section in all files referenced by the HINF to locate the indexed line. /// /// /// Note /// /// The setupapi.h header defines SetupGetLineByIndex 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-setupgetlinebyindexa WINSETUPAPI BOOL // SetupGetLineByIndexA( HINF InfHandle, PCSTR Section, DWORD Index, PINFCONTEXT Context ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetLineByIndexA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetLineByIndex(HINF InfHandle, [MarshalAs(UnmanagedType.LPTStr)] string Section, uint Index, out INFCONTEXT 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 SetupGetLineCount function returns the number of lines in a specified section of an INF file. /// /// Handle to the INF file. /// Pointer to a null-terminated string that specifies the section in which you want to count the lines. /// /// /// If InfHandle references multiple INF files that have been appended using SetupOpenAppendInfFile, this function returns the sum /// of the lines in all of the INF files containing the specified section. A return value of 0 specifies an empty section. If the /// section does not exist, the function returns –1. /// /// To get extended error information, call GetLastError. /// /// /// Note /// /// The setupapi.h header defines SetupGetLineCount 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-setupgetlinecounta WINSETUPAPI LONG SetupGetLineCountA( // HINF InfHandle, PCSTR Section ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetLineCountA")] public static extern int SetupGetLineCount(HINF InfHandle, [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 SetupGetLineText function returns the contents of a line in an INF file in a compact form. The line to retrieve can /// be specified by an INFCONTEXT structure returned from a SetupFindLineXXX function, or by explicitly passing in the INF handle, /// section, and key of the desired line. /// /// /// /// Context for a line in an INF file whose text is to be retrieved. This parameter can be NULL. If Context is NULL, /// InfHandle, Section, and Key must all be specified. /// /// /// Handle to the INF file to query. This parameter can be NULL. This parameter is used only if Context is NULL. If /// Context is NULL, InfHandle, Section, and Key must all be specified. /// /// /// Pointer to a null-terminated string that specifies the section that contains the key name of the line whose text is to be /// retrieved. This parameter can be NULL. This parameter is used only if Context is NULL. If Context is NULL, /// InfHandle, Section, and Key must be specified. /// /// /// Pointer to a null-terminated string that contains the key name whose associated string is to be retrieved. This parameter /// can be NULL. This parameter is used only if Context is NULL. If Context is NULL, InfHandle, Section, and /// Key must be specified. /// /// /// If not NULL, ReturnBuffer points to a buffer in which this function returns the contents of the line. The /// null-terminated string must 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 includes the null terminator. /// /// /// If not NULL, points to a variable in which this function returns the required size for the buffer pointed to by the /// ReturnBuffer parameter, in characters. This includes the null terminator. If ReturnBuffer is specified and the size /// required is larger than the value specified in the ReturnBufferSize parameter, the function fails and does not store data in the 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 /// required 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. /// /// /// This function returns the contents of a line in a compact format. All extraneous white space is removed and multi-line values /// are converted into a single contiguous string. For example, this line: /// /// /// HKLM, , PointerClass0, 1 \ ; This is a comment 01, 02, 03 /// /// would be returned as: /// /// HKLM,,PointerClass0,1,01,02,03 /// /// /// Note /// /// The setupapi.h header defines SetupGetLineText 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-setupgetlinetexta WINSETUPAPI BOOL SetupGetLineTextA( // PINFCONTEXT Context, HINF InfHandle, PCSTR Section, PCSTR Key, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetLineTextA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetLineText(in INFCONTEXT Context, [In, Optional] HINF InfHandle, [In, Optional, MarshalAs(UnmanagedType.LPTStr)] string? Section, [In, 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 SetupGetLineText function returns the contents of a line in an INF file in a compact form. The line to retrieve can /// be specified by an INFCONTEXT structure returned from a SetupFindLineXXX function, or by explicitly passing in the INF handle, /// section, and key of the desired line. /// /// /// /// Context for a line in an INF file whose text is to be retrieved. This parameter can be NULL. If Context is NULL, /// InfHandle, Section, and Key must all be specified. /// /// /// Handle to the INF file to query. This parameter can be NULL. This parameter is used only if Context is NULL. If /// Context is NULL, InfHandle, Section, and Key must all be specified. /// /// /// Pointer to a null-terminated string that specifies the section that contains the key name of the line whose text is to be /// retrieved. This parameter can be NULL. This parameter is used only if Context is NULL. If Context is NULL, /// InfHandle, Section, and Key must be specified. /// /// /// Pointer to a null-terminated string that contains the key name whose associated string is to be retrieved. This parameter /// can be NULL. This parameter is used only if Context is NULL. If Context is NULL, InfHandle, Section, and /// Key must be specified. /// /// /// If not NULL, ReturnBuffer points to a buffer in which this function returns the contents of the line. The /// null-terminated string must 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 includes the null terminator. /// /// /// If not NULL, points to a variable in which this function returns the required size for the buffer pointed to by the /// ReturnBuffer parameter, in characters. This includes the null terminator. If ReturnBuffer is specified and the size /// required is larger than the value specified in the ReturnBufferSize parameter, the function fails and does not store data in the 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 /// required 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. /// /// /// This function returns the contents of a line in a compact format. All extraneous white space is removed and multi-line values /// are converted into a single contiguous string. For example, this line: /// /// /// HKLM, , PointerClass0, 1 \ ; This is a comment 01, 02, 03 /// /// would be returned as: /// /// HKLM,,PointerClass0,1,01,02,03 /// /// /// Note /// /// The setupapi.h header defines SetupGetLineText 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-setupgetlinetexta WINSETUPAPI BOOL SetupGetLineTextA( // PINFCONTEXT Context, HINF InfHandle, PCSTR Section, PCSTR Key, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetLineTextA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetLineText([In, Optional] IntPtr Context, [In] HINF InfHandle, [In, MarshalAs(UnmanagedType.LPTStr)] string Section, [In, 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 SetupGetMultiSzField function retrieves multiple strings stored in a line of an INF file, from the specified field to /// the end of the line. /// /// /// Pointer to the context for a line in an INF file. /// /// The 1-based index of the starting field within the specified line from which the strings should be retrieved. The string list is /// built from each field starting at this point to the end of the line. A FieldIndex of zero is not valid with this function. /// /// /// Optional pointer to a character buffer that receives the strings. Each string is null-terminated, with an extra /// null at the end of the string list. 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 ReturnBuffer, in characters. This includes the null terminator. /// /// /// Optional pointer to a variable that receives the size required for the buffer pointed to by ReturnBuffer, in characters. This /// includes the null terminator. If the size needed 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. /// /// /// SetupGetMultiSzField should not be used to iterate through string values on an INF line. Instead you should use /// SetupGetStringField. SetupGetMultiSzField returns a value in the format of REG_MULTI_SZ. This is an array of /// null-terminated strings terminated by an extra null character. This format does not allow zero-length strings. If /// the list of strings contains any zero-length strings, SetupGetMultiSzField will return prematurely when it encounters the /// first blank string value. /// /// /// Note /// /// The setupapi.h header defines SetupGetMultiSzField 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-setupgetmultiszfielda WINSETUPAPI BOOL // SetupGetMultiSzFieldA( PINFCONTEXT Context, DWORD FieldIndex, PSTR ReturnBuffer, DWORD ReturnBufferSize, LPDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetMultiSzFieldA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetMultiSzField(in INFCONTEXT Context, uint FieldIndex, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder? ReturnBuffer, uint ReturnBufferSize, out uint RequiredSize); /// /// The SetupGetNonInteractiveMode function returns the value of a SetupAPI non-interactive flag that indicates whether the /// caller's process can interact with a user through user interface components, such as dialog boxes. /// /// /// SetupGetNonInteractiveMode returns TRUE if the caller's process cannot display interactive user interface /// elements, such as dialog boxes. Otherwise, the function returns FALSE, which indicates that the process can display /// interactive user interface elements. /// /// /// /// Installation applications and co-installers can use this function to determine whether the current process can display /// interactive user interface elements such as dialog boxes. SetupAPI runs a class installer or a co-installer either in an /// interactive or in a non-interactive process, depending on which DIF code SetupAPI is processing. /// /// /// An installation application can call SetupSetNonInteractiveMode to set the SetupAPI non-interactive flag that controls whether /// SetupAPI can display interactive user interface elements in the caller's context. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupgetnoninteractivemode WINSETUPAPI BOOL SetupGetNonInteractiveMode(); [DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetNonInteractiveMode")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetNonInteractiveMode(); /// /// /// [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 SetupGetSourceFileLocation function retrieves the location of a source file listed in an INF file. /// /// /// Handle to the 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 will be used. /// /// /// Optional pointer to the context of a line in a Copy Files section for which the full source path is to be retrieved. If /// this parameter is NULL, FileName is searched for in the SourceDisksFiles section of the INF file specified by InfHandle. /// /// /// Optional pointer to a null-terminated string containing the filename (no path) for which to return the full source /// location. This parameter can be NULL, but either FileName or InfContext must be specified. /// /// /// Pointer to a variable that receives the source identifier of the media where the file is located from the /// SourceDisksNames section of the INF file. /// /// /// Optional pointer to a buffer to receive the relative source path. The source path does not include the filename itself, nor does /// it include a drive letter/network share name. The path does not start or end with a backslash (), so the empty string specifies /// the root directory. You should use a null-terminated string buffer. 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 ReturnBuffer, in characters. This number includes the null terminator. /// /// /// Optional pointer to a variable that receives the required size for the buffer pointed to by the ReturnBuffer parameter, in /// characters. This number includes the null terminator. If the required size is larger than the value specified by /// ReturnBufferSize, the function fails and 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 SetupGetSourceFileLocation 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-setupgetsourcefilelocationa WINSETUPAPI BOOL // SetupGetSourceFileLocationA( HINF InfHandle, PINFCONTEXT InfContext, PCSTR FileName, PUINT SourceId, PSTR ReturnBuffer, DWORD // ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetSourceFileLocationA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetSourceFileLocation(HINF InfHandle, in INFCONTEXT InfContext, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? FileName, out uint SourceId, [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 SetupGetSourceFileLocation function retrieves the location of a source file listed in an INF file. /// /// /// Handle to the 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 will be used. /// /// /// Optional pointer to the context of a line in a Copy Files section for which the full source path is to be retrieved. If /// this parameter is NULL, FileName is searched for in the SourceDisksFiles section of the INF file specified by InfHandle. /// /// /// Optional pointer to a null-terminated string containing the filename (no path) for which to return the full source /// location. This parameter can be NULL, but either FileName or InfContext must be specified. /// /// /// Pointer to a variable that receives the source identifier of the media where the file is located from the /// SourceDisksNames section of the INF file. /// /// /// Optional pointer to a buffer to receive the relative source path. The source path does not include the filename itself, nor does /// it include a drive letter/network share name. The path does not start or end with a backslash (), so the empty string specifies /// the root directory. You should use a null-terminated string buffer. 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 ReturnBuffer, in characters. This number includes the null terminator. /// /// /// Optional pointer to a variable that receives the required size for the buffer pointed to by the ReturnBuffer parameter, in /// characters. This number includes the null terminator. If the required size is larger than the value specified by /// ReturnBufferSize, the function fails and 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 SetupGetSourceFileLocation 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-setupgetsourcefilelocationa WINSETUPAPI BOOL // SetupGetSourceFileLocationA( HINF InfHandle, PINFCONTEXT InfContext, PCSTR FileName, PUINT SourceId, PSTR ReturnBuffer, DWORD // ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetSourceFileLocationA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetSourceFileLocation(HINF InfHandle, [In, Optional] IntPtr InfContext, [MarshalAs(UnmanagedType.LPTStr)] string FileName, out uint SourceId, [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 SetupGetSourceFileSize function reads the uncompressed size of a source file listed in an INF file. /// /// /// Handle to the loaded 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 will be used. /// /// /// Optional pointer to a context for a line in a Copy Files section for which the size is to be retrieved. If InfContext is /// NULL, the FileName parameter is used. /// /// /// Optional pointer to a null-terminated string containing the filename (no path) for which to return the size. If this /// parameter is NULL as well as InfContext, then the Section parameter is used. /// /// /// Optional pointer to a null-terminated string containing the name of a Copy Files section. If this parameter is /// specified, the total size of all files listed in the section is computed. /// /// Pointer to a variable that receives the size, in bytes, of the specified file(s). /// /// Optional value for rounding file sizes. All file sizes are rounded up to a multiple of this number before being added to the /// total size. Rounding is useful for more exact determinations of the space that a file will occupy on a given volume, because it /// allows the caller to have file sizes rounded up to a multiple of the cluster size. Rounding does not occur unless RoundingFactor /// is specified. /// /// /// 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. /// /// /// One and only one of the optional parameters, InfContext, FileName, and Section, must be specified. /// /// Note /// /// The setupapi.h header defines SetupGetSourceFileSize 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-setupgetsourcefilesizea WINSETUPAPI BOOL // SetupGetSourceFileSizeA( HINF InfHandle, PINFCONTEXT InfContext, PCSTR FileName, PCSTR Section, PDWORD FileSize, UINT // RoundingFactor ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetSourceFileSizeA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetSourceFileSize(HINF InfHandle, in INFCONTEXT InfContext, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? FileName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? Section, out uint FileSize, uint RoundingFactor = 0); /// /// /// [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 SetupGetSourceFileSize function reads the uncompressed size of a source file listed in an INF file. /// /// /// Handle to the loaded 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 will be used. /// /// /// Optional pointer to a context for a line in a Copy Files section for which the size is to be retrieved. If InfContext is /// NULL, the FileName parameter is used. /// /// /// Optional pointer to a null-terminated string containing the filename (no path) for which to return the size. If this /// parameter is NULL as well as InfContext, then the Section parameter is used. /// /// /// Optional pointer to a null-terminated string containing the name of a Copy Files section. If this parameter is /// specified, the total size of all files listed in the section is computed. /// /// Pointer to a variable that receives the size, in bytes, of the specified file(s). /// /// Optional value for rounding file sizes. All file sizes are rounded up to a multiple of this number before being added to the /// total size. Rounding is useful for more exact determinations of the space that a file will occupy on a given volume, because it /// allows the caller to have file sizes rounded up to a multiple of the cluster size. Rounding does not occur unless RoundingFactor /// is specified. /// /// /// 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. /// /// /// One and only one of the optional parameters, InfContext, FileName, and Section, must be specified. /// /// Note /// /// The setupapi.h header defines SetupGetSourceFileSize 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-setupgetsourcefilesizea WINSETUPAPI BOOL // SetupGetSourceFileSizeA( HINF InfHandle, PINFCONTEXT InfContext, PCSTR FileName, PCSTR Section, PDWORD FileSize, UINT // RoundingFactor ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetSourceFileSizeA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetSourceFileSize(HINF InfHandle, [In, Optional] IntPtr InfContext, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? FileName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? Section, out uint FileSize, uint RoundingFactor = 0); /// /// /// [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 SetupGetSourceInfo function retrieves the path, tag file, or media description for a source listed in an INF file. /// /// /// /// Handle to an open INF file that contains a SourceDisksNames section. If platform-specific sections exist for the user's /// system (for example, SourceDisksNames.x86), the platform-specific section will be used. /// /// Identifier for a source media. This value is used to search by key in the SourceDisksNames section. /// /// /// Indicates what information is desired. Only one value may be specified per function call, and they cannot be combined. The /// following types of information can be retrieved from a SourceDisksNames section. /// /// SRCINFO_PATH /// The path specified for the source. This is not a full path, but the path relative to the installation root. /// SRCINFO_TAGFILE /// The tag file that identifies the source media, or if cabinets are used, the name of the cabinet file. /// SRCINFO_DESCRIPTION /// A description for the media. /// /// /// Optional pointer to a buffer to receive the retrieved information. Path returns are guaranteed not to end with . 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 ReturnBuffer, in characters. This includes the null terminator. /// /// /// Optional pointer to a variable that receives the required size for the buffer specified by ReturnBuffer, in characters. This /// includes the null terminator. If ReturnBuffer is specified and the actual size needed 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. /// /// /// Note /// /// The setupapi.h header defines SetupGetSourceInfo 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-setupgetsourceinfoa WINSETUPAPI BOOL SetupGetSourceInfoA( // HINF InfHandle, UINT SourceId, UINT InfoDesired, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetSourceInfoA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetSourceInfo(HINF InfHandle, uint SourceId, SRCINFO InfoDesired, [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 SetupGetStringField function retrieves a string from the specified field of a line in an INF file. /// /// Pointer to the context for a line in an INF file. /// /// The 1-based index of the field within the specified line from which the string should be retrieved. Use a FieldIndex of 0 to /// retrieve a string key, if present. /// /// /// Optional pointer to a buffer that receives the null-terminated string. You should ensure the destination buffer is the /// same size or larger than the source buffer. This parameter can be NULL. See the Remarks section. /// /// /// Size of the buffer pointed to by ReturnBuffer, in characters. This includes the null terminator. /// /// /// Optional pointer to a variable that receives the required size for the buffer pointed to by the ReturnBuffer parameter, in /// characters. If ReturnBuffer is specified and the actual size needed is larger than the value specified by ReturnBufferSize, the /// function fails and does not store the string in the buffer. In this case, a call to GetLastError returns /// ERROR_INSUFFICIENT_BUFFER. For the Unicode version of this function, the required size is 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 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. /// /// /// 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. /// /// /// Note that the maximum length of any single string specified in an INF Strings section is 512 characters, including the /// terminating NULL. If the string length is greater than 512 it will be truncated and no error will be returned. The /// maximum length of any concatenated string created from one or more %strkey% tokens is 4096 characters. /// /// /// Note /// /// The setupapi.h header defines SetupGetStringField 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-setupgetstringfielda WINSETUPAPI BOOL // SetupGetStringFieldA( PINFCONTEXT Context, DWORD FieldIndex, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetStringFieldA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetStringField(in INFCONTEXT Context, uint FieldIndex, [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 SetupGetTargetPath function determines the target directory for a file list section. The file list section can be a /// Copy Files section, a Delete Files section, or a Rename Files section. All the files in the section must be /// in a single directory that is listed in a DestinationDirs section of the INF file. /// /// /// Handle to the load INF file that contains a DestinationDirs section. /// /// Optional pointer to an INF context that specifies a line in a file list section whose destination directory is to be retrieved. /// If InfContext is NULL, then the Section parameter is used. /// /// /// Optional parameter that specifies the name of a section of the INF file whose handle is InfHandle. SetupGetTargetPath /// retrieves the target directory for this section. The Section parameter is ignored if InfContext is specified. If neither /// InfContext nor Section is specified, the function retrieves the default target path from the INF file. You should use a /// null-terminated string. /// /// /// Optional pointer to buffer to receive the fully qualified target path. The path is guaranteed not to end with . You should use a /// null-terminated string. 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 ReturnBuffer, in characters. This includes the null terminator. /// /// /// Optional pointer to a variable that receives the required size for the buffer pointed to by ReturnBuffer, in characters. This /// includes the null terminator. If the actual size needed 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. /// /// /// Note /// /// The setupapi.h header defines SetupGetTargetPath 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-setupgettargetpatha WINSETUPAPI BOOL SetupGetTargetPathA( // HINF InfHandle, PINFCONTEXT InfContext, PCSTR Section, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetTargetPathA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetTargetPath(HINF InfHandle, in INFCONTEXT InfContext, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? Section, [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 SetupGetTargetPath function determines the target directory for a file list section. The file list section can be a /// Copy Files section, a Delete Files section, or a Rename Files section. All the files in the section must be /// in a single directory that is listed in a DestinationDirs section of the INF file. /// /// /// Handle to the load INF file that contains a DestinationDirs section. /// /// Optional pointer to an INF context that specifies a line in a file list section whose destination directory is to be retrieved. /// If InfContext is NULL, then the Section parameter is used. /// /// /// Optional parameter that specifies the name of a section of the INF file whose handle is InfHandle. SetupGetTargetPath /// retrieves the target directory for this section. The Section parameter is ignored if InfContext is specified. If neither /// InfContext nor Section is specified, the function retrieves the default target path from the INF file. You should use a /// null-terminated string. /// /// /// Optional pointer to buffer to receive the fully qualified target path. The path is guaranteed not to end with . You should use a /// null-terminated string. 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 ReturnBuffer, in characters. This includes the null terminator. /// /// /// Optional pointer to a variable that receives the required size for the buffer pointed to by ReturnBuffer, in characters. This /// includes the null terminator. If the actual size needed 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. /// /// /// Note /// /// The setupapi.h header defines SetupGetTargetPath 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-setupgettargetpatha WINSETUPAPI BOOL SetupGetTargetPathA( // HINF InfHandle, PINFCONTEXT InfContext, PCSTR Section, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetTargetPathA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupGetTargetPath(HINF InfHandle, [In, Optional] IntPtr InfContext, [Optional, MarshalAs(UnmanagedType.LPTStr)] string? Section, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder ReturnBuffer, uint ReturnBufferSize, out uint RequiredSize); /// The SetupGetThreadLogToken function retrieves the log token for the thread from which this function was called. /// /// SetupGetThreadLogToken returns the log token for the thread from which the function was called. If a log token is not set /// for the thread, SetupGetThreadLogToken returns the system-defined log token LOGTOKEN_UNSPECIFIED. /// /// /// To set a log token for a thread, call SetupSetThreadLogToken. /// 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-setupgetthreadlogtoken WINSETUPAPI SP_LOG_TOKEN SetupGetThreadLogToken(); [DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupGetThreadLogToken")] public static extern ulong SetupGetThreadLogToken(); /// /// /// [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 SetupInitDefaultQueueCallback function initializes the context used by the default queue callback routine included /// with the Setup API. /// /// /// Handle to the window to use as the parent of any dialog boxes generated by the default callback routine. /// /// Pointer to the context used by the default queue callback routine. /// If the call to SetupInitDefaultQueueCallback fails, the function returns a PVOID value of null. /// 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-setupinitdefaultqueuecallback WINSETUPAPI PVOID // SetupInitDefaultQueueCallback( HWND OwnerWindow ); [DllImport(Lib_SetupAPI, SetLastError = true, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInitDefaultQueueCallback")] public static extern IntPtr SetupInitDefaultQueueCallback([In, Optional] HWND OwnerWindow); /// /// /// [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 SetupInitDefaultQueueCallbackEx function initializes the context used by the default queue callback routine included /// with the Setup API in the same manner as SetupInitDefaultQueueCallback, except that an additional window is provided to the /// callback function to accept progress messages. /// /// /// Handle to the window to use as the parent of any dialog boxes generated by the default callback routine. /// /// Handle to a window that receives the progress messages. To prevent progress messages from being displayed, you can specify this /// parameter to be INVALID_HANDLE_VALUE. /// /// /// Message that is sent to AlternateProgressWindow when the copy queue is started, and each time a file is copied. /// /// First message parameter that is sent to the AlternateProgressWindow by the default callback routine. /// Second message parameter that is sent to the AlternateProgressWindow by the default callback routine. /// /// SetupInitDefaultQueueCallbackEx returns a pointer to the context used by the default queue callback routine. This /// function can only fail if there is insufficient memory. If this function fails, it returns NULL and does not set the /// last-error code for the thread. /// /// /// /// When the queue starts to commit the copy subqueue, the default queue callback routine sends a message to the window specified in /// AlternateProgressWindow. Reserved1 has the value 0, and Reserved2 contains a pointer to the number of enqueued file copy operations. /// /// /// For each file copy operation completed, the default queue callback routine sends a message to AlternateProgressWindow, which can /// be used to 'tick' the progress bar. Reserved1 has the value 1, and Reserved2 is zero. /// /// /// SetupInitDefaultQueueCallbackEx can be used to get the default behavior for disk prompting, error handling, and so on, /// and also provide a gauge embedded in a wizard page or other specialized dialog box. /// /// /// 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-setupinitdefaultqueuecallbackex WINSETUPAPI PVOID // SetupInitDefaultQueueCallbackEx( HWND OwnerWindow, HWND AlternateProgressWindow, UINT ProgressMessage, DWORD Reserved1, PVOID // Reserved2 ); [DllImport(Lib_SetupAPI, SetLastError = false, ExactSpelling = true)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInitDefaultQueueCallbackEx")] public static extern IntPtr SetupInitDefaultQueueCallbackEx([In, Optional] HWND OwnerWindow, [In, Optional] HWND AlternateProgressWindow, uint ProgressMessage, [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 SetupInitializeFileLog function initializes a file to record installation operations and outcomes. This can be the /// system log, where the system tracks the files installed as part of Windows, or any other file. /// /// /// /// Optional pointer to the file name of the file to use as the log file. You should use a null-terminated string. The /// LogFileName parameter must be specified if Flags does not include SPFILELOG_SYSTEMLOG. The LogFileName parameter must not be /// specified if Flags includes SPFILELOG_SYSTEMLOG. This parameter can be NULL. /// /// /// Controls the log file initialization. This parameter can be a combination of the following values. /// SPFILELOG_SYSTEMLOG /// /// Use the system file log. The user must be an Administrator to specify this option unless SPFILELOG_QUERYONLY is specified and /// LogFileName is not specified. Do not specify SPFILELOG_SYSTEMLOG in combination with SPFILELOG_FORCENEW. /// /// SPFILELOG_FORCENEW /// /// If the log file exists, overwrite it. If the log file exists and this flag is not specified, any new files that are installed /// are added to the list in the existing log file. Do not specify in combination with SPFILELOG_SYSTEMLOG. /// /// SPFILELOG_QUERYONLY /// Open the log file for querying only. /// /// /// The function returns the handle to the log file if it is successful. Otherwise, the return value is INVALID_HANDLE_VALUE and the /// logged error can be retrieved by a call to GetLastError. /// /// /// Note /// /// The setupapi.h header defines SetupInitializeFileLog 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-setupinitializefileloga WINSETUPAPI HSPFILELOG // SetupInitializeFileLogA( PCSTR LogFileName, DWORD Flags ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInitializeFileLogA")] public static extern SafeHSPFILELOG SetupInitializeFileLog([Optional, MarshalAs(UnmanagedType.LPTStr)] string? LogFileName, SPFILELOG 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 SetupInstallFile function installs a file as specified either by an INFCONTEXT returned by SetupFindXXXLine or /// explicitly by the file name and path. /// /// If a file is copied, the caller of this function must have write privileges into the target directory. /// /// /// Optional pointer to the handle to an INF file that contains 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 /// will be used. If InfContext is null and CopyStyle includes SP_COPY_SOURCE_ABSOLUTE or SP_COPY_SOURCEPATH_ABSOLUTE, InfHandle is ignored. /// /// /// Optional pointer to the context of a line in a Copy Files section in an INF file. The routine looks up this file in the /// SourceDisksFiles section of InfHandle to get file copy information. If InfHandle is not specified, SourceFile must be. /// /// /// Optional pointer to the file name (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. 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 the file name 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 path and file /// name for the target. /// /// /// Flags that control the behavior of the file copy operation. These flags may be a combination of the following values. /// /// /// Value /// Meaning /// /// /// SP_COPY_DELETESOURCE /// Deletes the source file upon successful copy. The caller is not notified if the delete operation fails. /// /// /// SP_COPY_REPLACEONLY /// /// Copies the file only if doing so would overwrite a file at the destination path. If the target does not exist, the function /// returns FALSE and GetLastError returns NO_ERROR. /// /// /// /// SP_COPY_NEWER_OR_SAME /// /// Examines 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 operation. If /// CopyMsgHandler is not specified, the file is not copied. /// /// /// /// SP_COPY_NEWER_ONLY /// /// Examine each file being copied to see if its version resources indicate that it is not newer than an existing copy on the /// target. If the source file is newer but not equal in version to the existing target, the file is copied. /// /// /// /// SP_COPY_NOOVERWRITE /// /// Check whether the target file exists, and, if so, notify the caller who may veto the copy. If CopyMsgHandler is not specified, /// the file is not overwritten. /// /// /// /// SP_COPY_NODECOMP /// /// Do not decompress the file. When this flag is set, the target file is not given the uncompressed form of the source name (if /// appropriate). For example, copying F:\x86\cmd.ex_ to \\install\temp results in a target file of \\install\temp\cmd.ex_. If the /// SP_COPY_NODECOMP flag was not specified, the file would be decompressed and the target would be called \\install\temp\cmd.exe. /// The file name part of DestinationName, if specified, is stripped and replaced with the file name of the source file. When /// SP_COPY_NODECOMP is specified, no language or version information can be checked. /// /// /// /// SP_COPY_LANGUAGEAWARE /// /// Examine each file being copied to see if its language differs from the language of any existing file already on the target. If /// so, and CopyMsgHandler is specified, the caller is notified and may cancel the copy. If CopyMsgHandler is not specified, the /// file is not copied. /// /// /// /// SP_COPY_SOURCE_ABSOLUTE /// SourceFile is a full source path. Do not look it up in the SourceDisksNames section of the INF file. /// /// /// SP_COPY_SOURCEPATH_ABSOLUTE /// /// SourcePathRoot is the full path part of the source file. Ignore the relative source specified in the SourceDisksNames section of /// the INF file for the source media where the file is located. This flag is ignored if SP_COPY_SOURCE_ABSOLUTE is specified. /// /// /// /// SP_COPY_FORCE_IN_USE /// If the target exists, behaves as if it is in use and queues the file for copying on the next system restart. /// /// /// SP_COPY_FORCE_NOOVERWRITE /// Checks whether the target file exists, and, if so, the file is not overwritten. The caller is not notified. /// /// /// SP_COPY_FORCE_NEWER /// /// Examines 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. The function returns FALSE, and GetLastError returns NO_ERROR. /// /// /// /// /// /// Optional pointer to a callback function to be notified of various conditions that may arise during the file copy operation. /// /// Optional pointer to a caller-defined value that is passed as the first parameter of the callback function. /// /// 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. /// /// /// /// /// If a UNC directory is specified as the target directory of a file installation, you must ensure it exists before you call /// SetupInstallFile. The setup functions do not check for the existence of nor create UNC directories. If the target UNC /// directory does not exist, the file installation will fail. /// /// /// Note /// /// The setupapi.h header defines SetupInstallFile 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-setupinstallfilea WINSETUPAPI BOOL SetupInstallFileA( // HINF InfHandle, PINFCONTEXT InfContext, PCSTR SourceFile, PCSTR SourcePathRoot, PCSTR DestinationName, DWORD CopyStyle, // PSP_FILE_CALLBACK_A CopyMsgHandler, PVOID Context ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallFileA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupInstallFile([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); /// /// /// [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 SetupInstallFile function installs a file as specified either by an INFCONTEXT returned by SetupFindXXXLine or /// explicitly by the file name and path. /// /// If a file is copied, the caller of this function must have write privileges into the target directory. /// /// /// Optional pointer to the handle to an INF file that contains 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 /// will be used. If InfContext is null and CopyStyle includes SP_COPY_SOURCE_ABSOLUTE or SP_COPY_SOURCEPATH_ABSOLUTE, InfHandle is ignored. /// /// /// Optional pointer to the context of a line in a Copy Files section in an INF file. The routine looks up this file in the /// SourceDisksFiles section of InfHandle to get file copy information. If InfHandle is not specified, SourceFile must be. /// /// /// Optional pointer to the file name (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. 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 the file name 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 path and file /// name for the target. /// /// /// Flags that control the behavior of the file copy operation. These flags may be a combination of the following values. /// /// /// Value /// Meaning /// /// /// SP_COPY_DELETESOURCE /// Deletes the source file upon successful copy. The caller is not notified if the delete operation fails. /// /// /// SP_COPY_REPLACEONLY /// /// Copies the file only if doing so would overwrite a file at the destination path. If the target does not exist, the function /// returns FALSE and GetLastError returns NO_ERROR. /// /// /// /// SP_COPY_NEWER_OR_SAME /// /// Examines 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 operation. If /// CopyMsgHandler is not specified, the file is not copied. /// /// /// /// SP_COPY_NEWER_ONLY /// /// Examine each file being copied to see if its version resources indicate that it is not newer than an existing copy on the /// target. If the source file is newer but not equal in version to the existing target, the file is copied. /// /// /// /// SP_COPY_NOOVERWRITE /// /// Check whether the target file exists, and, if so, notify the caller who may veto the copy. If CopyMsgHandler is not specified, /// the file is not overwritten. /// /// /// /// SP_COPY_NODECOMP /// /// Do not decompress the file. When this flag is set, the target file is not given the uncompressed form of the source name (if /// appropriate). For example, copying F:\x86\cmd.ex_ to \\install\temp results in a target file of \\install\temp\cmd.ex_. If the /// SP_COPY_NODECOMP flag was not specified, the file would be decompressed and the target would be called \\install\temp\cmd.exe. /// The file name part of DestinationName, if specified, is stripped and replaced with the file name of the source file. When /// SP_COPY_NODECOMP is specified, no language or version information can be checked. /// /// /// /// SP_COPY_LANGUAGEAWARE /// /// Examine each file being copied to see if its language differs from the language of any existing file already on the target. If /// so, and CopyMsgHandler is specified, the caller is notified and may cancel the copy. If CopyMsgHandler is not specified, the /// file is not copied. /// /// /// /// SP_COPY_SOURCE_ABSOLUTE /// SourceFile is a full source path. Do not look it up in the SourceDisksNames section of the INF file. /// /// /// SP_COPY_SOURCEPATH_ABSOLUTE /// /// SourcePathRoot is the full path part of the source file. Ignore the relative source specified in the SourceDisksNames section of /// the INF file for the source media where the file is located. This flag is ignored if SP_COPY_SOURCE_ABSOLUTE is specified. /// /// /// /// SP_COPY_FORCE_IN_USE /// If the target exists, behaves as if it is in use and queues the file for copying on the next system restart. /// /// /// SP_COPY_FORCE_NOOVERWRITE /// Checks whether the target file exists, and, if so, the file is not overwritten. The caller is not notified. /// /// /// SP_COPY_FORCE_NEWER /// /// Examines 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. The function returns FALSE, and GetLastError returns NO_ERROR. /// /// /// /// /// /// Optional pointer to a callback function to be notified of various conditions that may arise during the file copy operation. /// /// Optional pointer to a caller-defined value that is passed as the first parameter of the callback function. /// /// 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. /// /// /// /// /// If a UNC directory is specified as the target directory of a file installation, you must ensure it exists before you call /// SetupInstallFile. The setup functions do not check for the existence of nor create UNC directories. If the target UNC /// directory does not exist, the file installation will fail. /// /// /// Note /// /// The setupapi.h header defines SetupInstallFile 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-setupinstallfilea WINSETUPAPI BOOL SetupInstallFileA( // HINF InfHandle, PINFCONTEXT InfContext, PCSTR SourceFile, PCSTR SourcePathRoot, PCSTR DestinationName, DWORD CopyStyle, // PSP_FILE_CALLBACK_A CopyMsgHandler, PVOID Context ); [DllImport(Lib_SetupAPI, SetLastError = true, CharSet = CharSet.Auto)] [PInvokeData("setupapi.h", MSDNShortId = "NF:setupapi.SetupInstallFileA")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetupInstallFile([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); }