diff --git a/PInvoke/Multimedia/MmIscApi.cs b/PInvoke/Multimedia/MmIscApi.cs
new file mode 100644
index 00000000..b720b212
--- /dev/null
+++ b/PInvoke/Multimedia/MmIscApi.cs
@@ -0,0 +1,2164 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using Vanara.InteropServices;
+
+namespace Vanara.PInvoke
+{
+ public static partial class WinMm
+ {
+ /// Processes driver messages for the installable driver. DriverProc is a driver-supplied function.
+ /// Identifier of the installable driver.
+ /// Handle of the installable driver instance. Each instance of the installable driver has a unique handle.
+ ///
+ /// Driver message value. It can be a custom value or one of these standard values:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// DRV_CLOSE
+ /// Notifies the driver that it should decrement its usage count and unload the driver if the count is zero.
+ ///
+ /// -
+ /// DRV_CONFIGURE
+ ///
+ /// Notifies the driver that it should display a configuration dialog box. This message is sent only if the driver returns a nonzero
+ /// value when processing the DRV_QUERYCONFIGURE message.
+ ///
+ ///
+ /// -
+ /// DRV_DISABLE
+ /// Notifies the driver that its allocated memory is about to be freed.
+ ///
+ /// -
+ /// DRV_ENABLE
+ /// Notifies the driver that it has been loaded or reloaded or that Windows has been enabled.
+ ///
+ /// -
+ /// DRV_FREE
+ /// Notifies the driver that it will be discarded.
+ ///
+ /// -
+ /// DRV_INSTALL
+ /// Notifies the driver that it has been successfully installed.
+ ///
+ /// -
+ /// DRV_LOAD
+ /// Notifies the driver that it has been successfully loaded.
+ ///
+ /// -
+ /// DRV_OPEN
+ /// Notifies the driver that it is about to be opened.
+ ///
+ /// -
+ /// DRV_POWER
+ /// Notifies the driver that the device's power source is about to be turned on or off.
+ ///
+ /// -
+ /// DRV_QUERYCONFIGURE
+ /// Directs the driver to specify whether it supports the DRV_CONFIGURE message.
+ ///
+ /// -
+ /// DRV_REMOVE
+ /// Notifies the driver that it is about to be removed from the system.
+ ///
+ ///
+ ///
+ /// 32-bit message-specific value.
+ /// 32-bit message-specific value.
+ /// Returns nonzero if successful or zero otherwise.
+ ///
+ ///
+ /// When msg is DRV_OPEN, lParam1 is the string following the driver filename from the SYSTEM.INI file and lParam2 is the value
+ /// given as the lParam parameter in a call to the OpenDriver function.
+ ///
+ ///
+ /// When msg is DRV_CLOSE, lParam1 and lParam2 are the same values as the lParam1 and lParam2 parameters in a call to the
+ /// CloseDriver function.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nc-mmiscapi-driverproc DRIVERPROC Driverproc; LRESULT Driverproc(
+ // DWORD_PTR unnamedParam1, HDRVR unnamedParam2, UINT unnamedParam3, LPARAM unnamedParam4, LPARAM unnamedParam5 ) {...}
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NC:mmiscapi.DRIVERPROC")]
+ public delegate IntPtr DRIVERPROC(IntPtr dwDriverIdentifier, HDRVR hdrvr, DRV uMsg, IntPtr lParam1, IntPtr lParam2);
+
+ ///
+ /// The MMIOProc function is a custom input/output (I/O) procedure installed by the mmioInstallIOProc function.
+ /// MMIOProc is a placeholder for the application-defined function name. The address of this function can be specified in the
+ /// callback-address parameter of mmioInstallIOProc.
+ ///
+ ///
+ /// Points to an MMIOINFO structure containing information about the open file.
+ ///
+ /// The I/O procedure must maintain the lDiskOffset member in this structure to indicate the file offset to the next read or
+ /// write location. The I/O procedure can use the adwInfo[] member to store state information. The I/O procedure should not
+ /// modify any other members of the MMIOINFO structure.
+ ///
+ ///
+ ///
+ /// Specifies a message indicating the requested I/O operation. Messages that can be received include MMIOM_OPEN, MMIOM_CLOSE,
+ /// MMIOM_READ, MMIOM_SEEK, MMIOM_WRITE, and MMIOM_WRITEFLUSH.
+ ///
+ /// Specifies an application-defined parameter for the message.
+ /// Specifies an application-defined parameter for the message.
+ ///
+ /// The return value depends on the message specified by uMsg. If the I/O procedure does not recognize a message, it should return zero.
+ ///
+ ///
+ ///
+ /// The four-character code specified by the fccMMIOProc member in the MMIOINFO structure associated with a file identifies a
+ /// file name extension for a custom storage system. When an application calls mmioOpen with a file name such as "one.xyz+two", the
+ /// I/O procedure associated with the four-character code "XYZ" is called to open the "two" element of the file "one.xyz".
+ ///
+ ///
+ /// The mmioInstallIOProc function maintains a separate list of installed I/O procedures for each Windows-based application.
+ /// Therefore, different applications can use the same I/O procedure identifier for different I/O procedures without conflict.
+ /// However, installing an I/O procedure globally enables any process to use the procedure.
+ ///
+ ///
+ /// If an application calls mmioInstallIOProc more than once to register the same I/O procedure, then it must call
+ /// mmioInstallIOProc to remove the procedure once for each time it installed the procedure.
+ ///
+ ///
+ /// mmioInstallIOProc will not prevent an application from installing two different I/O procedures with the same identifier, or
+ /// installing an I/O procedure with one of the predefined identifiers ("DOS ", "MEM "). The most recently installed procedure takes
+ /// precedence, and the most recently installed procedure is the first one to be removed.
+ ///
+ /// When searching for a specified I/O procedure, local procedures are searched first, then global procedures.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nc-mmiscapi-mmioproc MMIOPROC Mmioproc; LRESULT Mmioproc( LPSTR
+ // lpmmioinfo, UINT uMsg, LPARAM lParam1, LPARAM lParam2 ) {...}
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NC:mmiscapi.MMIOPROC")]
+ public delegate IntPtr MMIOPROC(ref MMIOINFO lpmmioinfo, MMIOM uMsg, IntPtr lParam1, IntPtr lParam2);
+
+ /// Notification flags.
+ [PInvokeData("mmddk.h")]
+ public enum DCB : uint
+ {
+ /// Unknown callback type
+ DCB_NULL = 0x0000,
+
+ ///
+ /// The dwCallback parameter is the handle of an application-defined window. The system sends subsequent notifications to the window.
+ ///
+ DCB_WINDOW = 0x0001,
+
+ ///
+ /// The dwCallback parameter is the handle of an application or task. The system sends subsequent notifications to the
+ /// application or task.
+ ///
+ DCB_TASK = 0x0002,
+
+ ///
+ /// The dwCallback parameter is the address of an application-defined callback function. The system sends the callback message
+ /// to the callback function.
+ ///
+ DCB_FUNCTION = 0x0003,
+
+ /// dwCallback is an EVENT
+ DCB_EVENT = 0x0005,
+
+ ///
+ /// The system is prevented from switching stacks. This value is only used if enough stack space for the callback function is
+ /// known to exist.
+ ///
+ DCB_NOSWITCH = 0x0008,
+ }
+
+ /// Driver message value. It can be a custom value or one of these standard values.
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NC:mmiscapi.DRIVERPROC")]
+ public enum DRV
+ {
+ /// Notifies the driver that it has been successfully loaded.
+ DRV_LOAD = 0x0001,
+
+ /// Notifies the driver that it has been loaded or reloaded or that Windows has been enabled.
+ DRV_ENABLE = 0x0002,
+
+ /// Notifies the driver that it is about to be opened.
+ DRV_OPEN = 0x0003,
+
+ /// Notifies the driver that it should decrement its usage count and unload the driver if the count is zero.
+ DRV_CLOSE = 0x0004,
+
+ /// Notifies the driver that its allocated memory is about to be freed.
+ DRV_DISABLE = 0x0005,
+
+ /// Notifies the driver that it will be discarded.
+ DRV_FREE = 0x0006,
+
+ ///
+ /// Notifies the driver that it should display a configuration dialog box. This message is sent only if the driver returns a
+ /// nonzero value when processing the DRV_QUERYCONFIGURE message.
+ ///
+ DRV_CONFIGURE = 0x0007,
+
+ /// Directs the driver to specify whether it supports the DRV_CONFIGURE message.
+ DRV_QUERYCONFIGURE = 0x0008,
+
+ /// Notifies the driver that it has been successfully installed.
+ DRV_INSTALL = 0x0009,
+
+ /// Notifies the driver that it is about to be removed from the system.
+ DRV_REMOVE = 0x000A,
+
+ ///
+ DRV_EXITSESSION = 0x000B,
+
+ /// Notifies the driver that the device's power source is about to be turned on or off.
+ DRV_POWER = 0x000F,
+
+ ///
+ DRV_RESERVED = 0x0800,
+
+ ///
+ DRV_USER = 0x4000,
+ }
+
+ ///
+ [Flags]
+ public enum MMIO : uint
+ {
+ /* constants for dwFlags field of MMIOINFO */
+
+ /// The mmioOpen function was directed to create the file (or truncate it to zero length if it already existed).
+ MMIO_CREATE = 0x00001000,
+
+ /// The new file's path is returned.
+ MMIO_PARSE = 0x00000100,
+
+ /// create new file (or truncate file)
+ MMIO_DELETE = 0x00000200,
+
+ /// Checks for the existence of the file.
+ MMIO_EXIST = 0x00004000,
+
+ /// File's I/O buffer was allocated by the mmioOpen or mmioSetBuffer function.
+ MMIO_ALLOCBUF = 0x00010000,
+
+ /// A temporary name was retrieved by the mmioOpen function.
+ MMIO_GETTEMP = 0x00020000,
+
+ /// The I/O buffer has been modified.
+ MMIO_DIRTY = 0x10000000,
+
+ /// File was opened only for reading.
+ MMIO_READ = 0x00000000,
+
+ /// File was opened only for writing.
+ MMIO_WRITE = 0x00000001,
+
+ /// File was opened for reading and writing.
+ MMIO_READWRITE = 0x00000002,
+
+ /* share mode numbers (bit field MMIO_SHAREMODE) */
+
+ ///
+ /// File was opened with compatibility mode, allowing any process on a given machine to open the file any number of times.
+ ///
+ MMIO_COMPAT = 0x00000000,
+
+ /// Other processes are denied read and write access to the file.
+ MMIO_EXCLUSIVE = 0x00000010,
+
+ /// Other processes are denied write access to the file.
+ MMIO_DENYWRITE = 0x00000020,
+
+ /// Other processes are denied read access to the file.
+ MMIO_DENYREAD = 0x00000030,
+
+ /// Other processes are not denied read or write access to the file.
+ MMIO_DENYNONE = 0x00000040,
+ }
+
+ /// Flags for the close operation.
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioClose")]
+ [Flags]
+ public enum MMIOCLOSE : uint
+ {
+ ///
+ /// If the file was opened by passing a file handle whose type is not HMMIO, using this flag tells the mmioClose function to
+ /// close the multimedia file handle, but not the standard file handle.
+ ///
+ MMIO_FHOPEN = 0x0010,
+ }
+
+ /// Flags for the conversion.
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioStringToFOURCC")]
+ [Flags]
+ public enum MMIOCONV : uint
+ {
+ /// Converts all characters to uppercase.
+ MMIO_TOUPPER = 0x0010,
+ }
+
+ /// Flags identifying what type of chunk to create.
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioCreateChunk")]
+ [Flags]
+ public enum MMIOCREATE : uint
+ {
+ /// RIFF chunk
+ MMIO_CREATERIFF = 0x0020,
+
+ /// LIST chunk
+ MMIO_CREATELIST = 0x0040,
+ }
+
+ ///
+ /// Search flags. If no flags are specified, mmioDescend descends into the chunk beginning at the current file position.
+ ///
+ [Flags]
+ public enum MMIODESC : uint
+ {
+ /// Searches for a chunk with the specified chunk identifier.
+ MMIO_FINDCHUNK = 0x0010,
+
+ /// Searches for a chunk with the chunk identifier "RIFF" and with the specified form type.
+ MMIO_FINDRIFF = 0x0020,
+
+ /// Searches for a chunk with the chunk identifier "LIST" and with the specified form type.
+ MMIO_FINDLIST = 0x0040,
+ }
+
+ /// Flag determining how the flush is carried out.
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioFlush")]
+ [Flags]
+ public enum MMIOFLUSH : uint
+ {
+ /// Empties the buffer after writing it to the disk.
+ MMIO_EMPTYBUF = 0x0010,
+ }
+
+ /// Flag indicating whether the I/O procedure is being installed, removed, or located.
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioInstallIOProc")]
+ [Flags]
+ public enum MMIOINST : uint
+ {
+ /// Installs the specified I/O procedure.
+ MMIO_INSTALLPROC = 0x00010000,
+
+ ///
+ /// This flag is a modifier to the MMIO_INSTALLPROC flag and indicates the I/O procedure should be installed for global use.
+ /// This flag is ignored if MMIO_FINDPROC or MMIO_REMOVEPROC is specified.
+ ///
+ MMIO_GLOBALPROC = 0x10000000,
+
+ /// Removes the specified I/O procedure.
+ MMIO_REMOVEPROC = 0x00020000,
+
+ /// Unicode MMIOProc
+ MMIO_UNICODEPROC = 0x01000000,
+
+ /// Searches for the specified I/O procedure.
+ MMIO_FINDPROC = 0x00040000,
+ }
+
+ /// MMIO messages.
+ [PInvokeData("mmiscapi.h")]
+ public enum MMIOM : uint
+ {
+ /// read
+ MMIOM_READ = MMIO.MMIO_READ,
+
+ /// write
+ MMIOM_WRITE = MMIO.MMIO_WRITE,
+
+ /// seek to a new position in file
+ MMIOM_SEEK = 2,
+
+ /// open file
+ MMIOM_OPEN = 3,
+
+ /// close file
+ MMIOM_CLOSE = 4,
+
+ /// write and flush
+ MMIOM_WRITEFLUSH = 5,
+
+ /// rename specified file
+ MMIOM_RENAME = 6,
+
+ /// beginning of user-defined messages
+ MMIOM_USER = 0x8000,
+ }
+
+ /// Closes an installable driver.
+ ///
+ /// Handle of an installable driver instance. The handle must have been previously created by using the OpenDriver function.
+ ///
+ /// 32-bit driver-specific data.
+ /// 32-bit driver-specific data.
+ /// Returns nonzero if successful or zero otherwise.
+ /// The function passes the lParam1 and lParam2 parameters to the DriverProc function of the installable driver.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-closedriver LRESULT CloseDriver( HDRVR hDriver, LPARAM
+ // lParam1, LPARAM lParam2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.CloseDriver")]
+ public static extern IntPtr CloseDriver(HDRVR hDriver, [In, Optional] IntPtr lParam1, [In, Optional] IntPtr lParam2);
+
+ ///
+ /// Provides default processing for any messages not processed by an installable driver. This function is intended to be used only
+ /// within the DriverProc function of an installable driver.
+ ///
+ /// Identifier of the installable driver.
+ /// Handle of the installable driver instance.
+ /// Driver message value.
+ /// 32-bit message-dependent information.
+ /// 32-bit message-dependent information.
+ /// Returns nonzero if successful or zero otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-defdriverproc LRESULT DefDriverProc( DWORD_PTR
+ // dwDriverIdentifier, HDRVR hdrvr, UINT uMsg, LPARAM lParam1, LPARAM lParam2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.DefDriverProc")]
+ public static extern IntPtr DefDriverProc(IntPtr dwDriverIdentifier, HDRVR hdrvr, DRV uMsg, IntPtr lParam1, IntPtr lParam2);
+
+ ///
+ /// Calls a callback function, sends a message to a window, or unblocks a thread. The action depends on the value of the
+ /// notification flag. This function is intended to be used only within the DriverProc function of an installable driver.
+ ///
+ ///
+ /// Address of the callback function, a window handle, or a task handle, depending on the flag specified in the dwFlags parameter.
+ ///
+ ///
+ /// Notification flags. It can be one of these values:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// DCB_NOSWITCH
+ ///
+ /// The system is prevented from switching stacks. This value is only used if enough stack space for the callback function is known
+ /// to exist.
+ ///
+ ///
+ /// -
+ /// DCB_FUNCTION
+ ///
+ /// The dwCallback parameter is the address of an application-defined callback function. The system sends the callback message to
+ /// the callback function.
+ ///
+ ///
+ /// -
+ /// DCB_WINDOW
+ ///
+ /// The dwCallback parameter is the handle of an application-defined window. The system sends subsequent notifications to the window.
+ ///
+ ///
+ /// -
+ /// DCB_TASK
+ ///
+ /// The dwCallback parameter is the handle of an application or task. The system sends subsequent notifications to the application
+ /// or task.
+ ///
+ ///
+ ///
+ ///
+ /// Handle of the installable driver instance.
+ /// Message value.
+ /// 32-bit user-instance data supplied by the application when the device was opened.
+ /// 32-bit message-dependent parameter.
+ /// 32-bit message-dependent parameter.
+ /// Returns TRUE if successful or FALSE if a parameter is invalid or the task's message queue is full.
+ ///
+ ///
+ /// The client specifies how to notify it when the device is opened. The DCB_FUNCTION and DCB_WINDOW flags are equivalent to the
+ /// high-order word of the corresponding flags CALLBACK_FUNCTION and CALLBACK_WINDOW specified in the lParam2 parameter of the
+ /// DRV_OPEN message when the device was opened.
+ ///
+ ///
+ /// If notification is accomplished with a callback function, hdrvr, msg, dwUser, dwParam1, and dwParam2 are passed to the callback
+ /// function. If notification is accomplished by means of a window, only msg, hdrvr, and dwParam1 are passed to the window.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-drivercallback BOOL DriverCallback( DWORD_PTR dwCallback,
+ // DWORD dwFlags, HDRVR hDevice, DWORD dwMsg, DWORD_PTR dwUser, DWORD_PTR dwParam1, DWORD_PTR dwParam2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.DriverCallback")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DriverCallback(IntPtr dwCallback, DCB dwFlags, HDRVR hDevice, uint dwMsg, IntPtr dwUser, IntPtr dwParam1, IntPtr dwParam2);
+
+ ///
+ /// Provides default processing for any messages not processed by an installable driver. This function is intended to be used only
+ /// within the DriverProc function of an installable driver.
+ ///
+ /// Identifier of the installable driver.
+ /// Handle of the installable driver instance.
+ /// Driver message value.
+ /// 32-bit message-dependent information.
+ /// 32-bit message-dependent information.
+ /// Returns nonzero if successful or zero otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-drvdefdriverproc LRESULT DrvDefDriverProc( DWORD
+ // dwDriverIdentifier, HDRVR hdrvr, UINT uMsg, LPARAM lParam1, LPARAM lParam2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.DrvDefDriverProc")]
+ public static extern IntPtr DrvDefDriverProc(uint dwDriverIdentifier, HDRVR hdrvr, uint uMsg, IntPtr lParam1, IntPtr lParam2);
+
+ ///
+ /// Retrieves the instance handle of the module that contains the installable driver. This function is provided for compatibility
+ /// with previous versions of Windows.
+ ///
+ ///
+ /// Handle of the installable driver instance. The handle must have been previously created by using the OpenDriver function.
+ ///
+ /// Returns an instance handle of the driver module if successful or NULL otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-drvgetmodulehandle HMODULE DrvGetModuleHandle( HDRVR
+ // hDriver );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.DrvGetModuleHandle")]
+ public static extern HINSTANCE DrvGetModuleHandle(HDRVR hDriver);
+
+ ///
+ /// The mmioAdvance function advances the I/O buffer of a file set up for direct I/O buffer access with the mmioGetInfo function.
+ ///
+ /// File handle of a file opened by using the mmioOpen function.
+ ///
+ /// Pointer to the MMIOINFO structure obtained by using the mmioGetInfo function. This structure is used to set the current file
+ /// information, and then it is updated after the buffer is advanced. This parameter is optional.
+ ///
+ ///
+ /// Flags for the operation. It can be one of the following.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// MMIO_READ
+ /// Buffer is filled from the file.
+ ///
+ /// -
+ /// MMIO_WRITE
+ /// Buffer is written to the file.
+ ///
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_CANNOTEXPAND
+ ///
+ /// The specified memory file cannot be expanded, probably because the adwInfo member of the MMIOINFO structure was set to zero in
+ /// the initial call to the mmioOpen function.
+ ///
+ ///
+ /// -
+ /// MMIOERR_CANNOTREAD
+ /// An error occurred while refilling the buffer.
+ ///
+ /// -
+ /// MMIOERR_CANNOTWRITE
+ /// The contents of the buffer could not be written to disk.
+ ///
+ /// -
+ /// MMIOERR_OUTOFMEMORY
+ /// There was not enough memory to expand a memory file for further writing.
+ ///
+ /// -
+ /// MMIOERR_UNBUFFERED
+ /// The specified file is not opened for buffered I/O.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If the file is opened for reading, the I/O buffer is filled from the disk. If the file is opened for writing and the MMIO_DIRTY
+ /// flag is set in the dwFlags member of the MMIOINFO structure, the buffer is written to disk. The
+ /// pchNext,pchEndRead, and pchEndWrite members of the MMIOINFO structure are updated to reflect the new
+ /// state of the I/O buffer.
+ ///
+ ///
+ /// If the specified file is opened for writing or for both reading and writing, the I/O buffer is flushed to disk before the next
+ /// buffer is read. If the I/O buffer cannot be written to disk because the disk is full, mmioAdvance returns MMIOERR_CANNOTWRITE.
+ ///
+ /// If the specified file is open only for writing, the MMIO_WRITE flag must be specified.
+ ///
+ /// If you have written to the I/O buffer, you must set the MMIO_DIRTY flag in the dwFlags member of the MMIOINFO
+ /// structure before calling mmioAdvance. Otherwise, the buffer will not be written to disk.
+ ///
+ ///
+ /// If the end of file is reached, mmioAdvance still returns successfully even though no more data can be read. To check for
+ /// the end of the file, check if the pchNext and pchEndRead members of the MMIOINFO structure are equal after
+ /// calling mmioAdvance.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioadvance MMRESULT mmioAdvance( HMMIO hmmio, LPMMIOINFO
+ // pmmioinfo, UINT fuAdvance );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioAdvance")]
+ public static extern MMRESULT mmioAdvance(HMMIO hmmio, in MMIOINFO pmmioinfo, MMIO fuAdvance);
+
+ ///
+ /// The mmioAdvance function advances the I/O buffer of a file set up for direct I/O buffer access with the mmioGetInfo function.
+ ///
+ /// File handle of a file opened by using the mmioOpen function.
+ ///
+ /// Pointer to the MMIOINFO structure obtained by using the mmioGetInfo function. This structure is used to set the current file
+ /// information, and then it is updated after the buffer is advanced. This parameter is optional.
+ ///
+ ///
+ /// Flags for the operation. It can be one of the following.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// MMIO_READ
+ /// Buffer is filled from the file.
+ ///
+ /// -
+ /// MMIO_WRITE
+ /// Buffer is written to the file.
+ ///
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_CANNOTEXPAND
+ ///
+ /// The specified memory file cannot be expanded, probably because the adwInfo member of the MMIOINFO structure was set to zero in
+ /// the initial call to the mmioOpen function.
+ ///
+ ///
+ /// -
+ /// MMIOERR_CANNOTREAD
+ /// An error occurred while refilling the buffer.
+ ///
+ /// -
+ /// MMIOERR_CANNOTWRITE
+ /// The contents of the buffer could not be written to disk.
+ ///
+ /// -
+ /// MMIOERR_OUTOFMEMORY
+ /// There was not enough memory to expand a memory file for further writing.
+ ///
+ /// -
+ /// MMIOERR_UNBUFFERED
+ /// The specified file is not opened for buffered I/O.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If the file is opened for reading, the I/O buffer is filled from the disk. If the file is opened for writing and the MMIO_DIRTY
+ /// flag is set in the dwFlags member of the MMIOINFO structure, the buffer is written to disk. The
+ /// pchNext,pchEndRead, and pchEndWrite members of the MMIOINFO structure are updated to reflect the new
+ /// state of the I/O buffer.
+ ///
+ ///
+ /// If the specified file is opened for writing or for both reading and writing, the I/O buffer is flushed to disk before the next
+ /// buffer is read. If the I/O buffer cannot be written to disk because the disk is full, mmioAdvance returns MMIOERR_CANNOTWRITE.
+ ///
+ /// If the specified file is open only for writing, the MMIO_WRITE flag must be specified.
+ ///
+ /// If you have written to the I/O buffer, you must set the MMIO_DIRTY flag in the dwFlags member of the MMIOINFO
+ /// structure before calling mmioAdvance. Otherwise, the buffer will not be written to disk.
+ ///
+ ///
+ /// If the end of file is reached, mmioAdvance still returns successfully even though no more data can be read. To check for
+ /// the end of the file, check if the pchNext and pchEndRead members of the MMIOINFO structure are equal after
+ /// calling mmioAdvance.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioadvance MMRESULT mmioAdvance( HMMIO hmmio, LPMMIOINFO
+ // pmmioinfo, UINT fuAdvance );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioAdvance")]
+ public static extern MMRESULT mmioAdvance(HMMIO hmmio, [In, Optional] IntPtr pmmioinfo, MMIO fuAdvance);
+
+ ///
+ /// The mmioAscend function ascends out of a chunk in a RIFF file descended into with the mmioDescend function or created
+ /// with the mmioCreateChunk function.
+ ///
+ /// File handle of an open RIFF file.
+ ///
+ /// Pointer to an application-defined MMCKINFO structure previously filled by the mmioDescend or mmioCreateChunk function.
+ ///
+ /// Reserved; must be zero.
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_CANNOTSEEK
+ /// There was an error while seeking to the end of the chunk.
+ ///
+ /// -
+ /// MMIOERR_CANNOTWRITE
+ /// The contents of the buffer could not be written to disk.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If the chunk was descended into by using mmioDescend, mmioAscend seeks to the location following the end of the chunk
+ /// (past the extra pad byte, if any).
+ ///
+ ///
+ /// If the chunk was created and descended into by using mmioCreateChunk, or if the MMIO_DIRTY flag is set in the
+ /// dwFlags member of the MMCKINFO structure referenced by lpck, the current file position is assumed to be the end of
+ /// the data portion of the chunk. If the chunk size is not the same as the value stored in the cksize member of the
+ /// MMCKINFO structure when mmioCreateChunk was called, mmioAscend corrects the chunk size in the file before
+ /// ascending from the chunk. If the chunk size is odd, mmioAscend writes a null pad byte at the end of the chunk. After
+ /// ascending from the chunk, the current file position is the location following the end of the chunk (past the extra pad byte, if any).
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioascend MMRESULT mmioAscend( HMMIO hmmio, LPMMCKINFO
+ // pmmcki, UINT fuAscend );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioAscend")]
+ public static extern MMRESULT mmioAscend(HMMIO hmmio, in MMCKINFO pmmcki, uint fuAscend = 0);
+
+ /// The mmioClose function closes a file that was opened by using the mmioOpen function.
+ /// File handle of the file to close.
+ ///
+ /// Flags for the close operation. The following value is defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// MMIO_FHOPEN
+ ///
+ /// If the file was opened by passing a file handle whose type is not HMMIO, using this flag tells the mmioClose function to close
+ /// the multimedia file handle, but not the standard file handle.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. The error value can originate from the mmioFlush function or from the I/O
+ /// procedure. Possible error values include the following.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_CANNOTWRITE
+ /// The contents of the buffer could not be written to disk.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioclose MMRESULT mmioClose( HMMIO hmmio, UINT fuClose );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioClose")]
+ public static extern MMRESULT mmioClose(HMMIO hmmio, MMIOCLOSE fuClose);
+
+ ///
+ /// The mmioCreateChunk function creates a chunk in a RIFF file that was opened by using the mmioOpen function. The new chunk
+ /// is created at the current file position. After the new chunk is created, the current file position is the beginning of the data
+ /// portion of the new chunk.
+ ///
+ /// File handle of an open RIFF file.
+ /// Pointer to a buffer that receives a MMCKINFO structure containing information about the chunk to be created.
+ ///
+ /// Flags identifying what type of chunk to create. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// MMIO_CREATELIST
+ /// "LIST" chunk.
+ ///
+ /// -
+ /// MMIO_CREATERIFF
+ /// "RIFF" chunk.
+ ///
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_CANNOTSEEK
+ /// Unable to determine offset of the data portion of the chunk.
+ ///
+ /// -
+ /// MMIOERR_CANNOTWRITE
+ /// Unable to write the chunk header.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function cannot insert a chunk into the middle of a file. If an application attempts to create a chunk somewhere other than
+ /// at the end of a file, mmioCreateChunk overwrites existing information in the file.
+ ///
+ /// The MMCKINFO structure pointed to by the lpck parameter should be set up as follows:
+ ///
+ /// -
+ ///
+ /// The ckid member specifies the chunk identifier. If wFlags includes MMIO_CREATERIFF or MMIO_CREATELIST, this member will
+ /// be filled by mmioCreateChunk.
+ ///
+ ///
+ /// -
+ ///
+ /// The cksize member specifies the size of the data portion of the chunk, including the form type or list type (if any). If
+ /// this value is not correct when the mmioAscend function is called to mark the end of the chunk, mmioAscend corrects the
+ /// chunk size.
+ ///
+ ///
+ /// -
+ ///
+ /// The fccType member specifies the form type or list type if the chunk is a "RIFF" or "LIST" chunk. If the chunk is not a
+ /// "RIFF" or "LIST" chunk, this member does not need to be filled in.
+ ///
+ ///
+ /// -
+ ///
+ /// The dwDataOffset member does not need to be filled in. The mmioCreateChunk function fills this member with the
+ /// file offset of the data portion of the chunk.
+ ///
+ ///
+ /// -
+ ///
+ /// The dwFlags member does not need to be filled in. The mmioCreateChunk function sets the MMIO_DIRTY flag in dwFlags.
+ ///
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiocreatechunk MMRESULT mmioCreateChunk( HMMIO hmmio,
+ // LPMMCKINFO pmmcki, UINT fuCreate );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioCreateChunk")]
+ public static extern MMRESULT mmioCreateChunk(HMMIO hmmio, in MMCKINFO pmmcki, MMIOCREATE fuCreate);
+
+ ///
+ /// The mmioDescend function descends into a chunk of a RIFF file that was opened by using the mmioOpen function. It can also
+ /// search for a given chunk.
+ ///
+ /// File handle of an open RIFF file.
+ /// Pointer to a buffer that receives an MMCKINFO structure.
+ ///
+ /// Pointer to an optional application-defined MMCKINFO structure identifying the parent of the chunk being searched for. If this
+ /// parameter is not NULL, mmioDescend assumes the MMCKINFO structure it refers to was filled when
+ /// mmioDescend was called to descend into the parent chunk, and mmioDescend searches for a chunk within the parent
+ /// chunk. Set this parameter to NULL if no parent chunk is being specified.
+ ///
+ ///
+ ///
+ /// Search flags. If no flags are specified, mmioDescend descends into the chunk beginning at the current file position. The
+ /// following values are defined.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// MMIO_FINDCHUNK
+ /// Searches for a chunk with the specified chunk identifier.
+ ///
+ /// -
+ /// MMIO_FINDLIST
+ /// Searches for a chunk with the chunk identifier "LIST" and with the specified form type.
+ ///
+ /// -
+ /// MMIO_FINDRIFF
+ /// Searches for a chunk with the chunk identifier "RIFF" and with the specified form type.
+ ///
+ ///
+ ///
+ ///
+ /// Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_CHUNKNOTFOUND
+ /// The end of the file (or the end of the parent chunk, if given) was reached before the desired chunk was found.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// A "RIFF" chunk consists of a four-byte chunk identifier (type FOURCC), followed by a four-byte chunk size (type
+ /// DWORD), followed by the data portion of the chunk, followed by a null pad byte if the size of the data portion is odd. If
+ /// the chunk identifier is "RIFF" or "LIST", the first four bytes of the data portion of the chunk are a form type or list type
+ /// (type FOURCC).
+ ///
+ ///
+ /// If you use mmioDescend to search for a chunk, make sure the file position is at the beginning of a chunk before calling
+ /// the function. The search begins at the current file position and continues to the end of the file. If a parent chunk is
+ /// specified, the file position should be somewhere within the parent chunk before calling mmioDescend. In this case, the
+ /// search begins at the current file position and continues to the end of the parent chunk.
+ ///
+ ///
+ /// If mmioDescend is unsuccessful in searching for a chunk, the current file position is undefined. If mmioDescend is
+ /// successful, the current file position is changed. If the chunk is a "RIFF" or "LIST" chunk, the new file position will be just
+ /// after the form type or list type (12 bytes from the beginning of the chunk). For other chunks, the new file position will be the
+ /// start of the data portion of the chunk (8 bytes from the beginning of the chunk).
+ ///
+ /// The mmioDescend function fills the MMCKINFO structure pointed to by the lpck parameter with the following information:
+ ///
+ /// -
+ ///
+ /// The ckid member is the chunk. If the MMIO_FINDCHUNK, MMIO_FINDRIFF, or MMIO_FINDLIST flag is specified for wFlags,
+ /// the MMCKINFO structure is also used to pass parameters to mmioDescend. In this case, the ckid member specifies the
+ /// four-character code of the chunk identifier, form type, or list type to search for.
+ ///
+ ///
+ /// -
+ ///
+ /// The cksize member is the size, in bytes, of the data portion of the chunk. The size includes the form type or list type
+ /// (if any), but does not include the 8-byte chunk header or the pad byte at the end of the data (if any).
+ ///
+ ///
+ /// -
+ ///
+ /// The fccType member is the form type if ckid is "RIFF", or the list type if ckid is "LIST". Otherwise, it is NULL.
+ ///
+ ///
+ /// -
+ ///
+ /// The dwDataOffset member is the file offset of the beginning of the data portion of the chunk. If the chunk is a "RIFF"
+ /// chunk or a "LIST" chunk, this member is the offset of the form type or list type.
+ ///
+ ///
+ /// -
+ ///
+ /// The dwFlags member contains other information about the chunk. Currently, this information is not used and is set to zero.
+ ///
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiodescend MMRESULT mmioDescend( HMMIO hmmio, LPMMCKINFO
+ // pmmcki, const MMCKINFO *pmmckiParent, UINT fuDescend );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioDescend")]
+ public static extern MMRESULT mmioDescend(HMMIO hmmio, ref MMCKINFO pmmcki, in MMCKINFO pmmckiParent, MMIODESC fuDescend);
+
+ /// The mmioFlush function writes the I/O buffer of a file to disk if the buffer has been written to.
+ /// File handle of a file opened by using the mmioOpen function.
+ ///
+ /// Flag determining how the flush is carried out. It can be zero or the following.
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// MMIO_EMPTYBUF
+ /// Empties the buffer after writing it to the disk.
+ ///
+ ///
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. Possible error values include the following.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_CANNOTWRITE
+ /// The contents of the buffer could not be written to disk.
+ ///
+ ///
+ ///
+ ///
+ /// Closing a file with the mmioClose function automatically flushes its buffer.
+ ///
+ /// If there is insufficient disk space to write the buffer, mmioFlush fails, even if the preceding calls of the mmioWrite
+ /// function were successful.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioflush MMRESULT mmioFlush( HMMIO hmmio, UINT fuFlush );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioFlush")]
+ public static extern MMRESULT mmioFlush(HMMIO hmmio, MMIOFLUSH fuFlush);
+
+ ///
+ /// The mmioGetInfo function retrieves information about a file opened by using the mmioOpen function. This information
+ /// allows the application to directly access the I/O buffer, if the file is opened for buffered I/O.
+ ///
+ /// File handle of the file.
+ ///
+ /// Pointer to a buffer that receives an MMIOINFO structure that mmioGetInfo fills with information about the file.
+ ///
+ /// Reserved; must be zero.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ ///
+ /// To directly access the I/O buffer of a file opened for buffered I/O, use the following members of the MMIOINFO structure filled
+ /// by mmioGetInfo:
+ ///
+ ///
+ /// -
+ ///
+ /// The pchNext member points to the next byte in the buffer that can be read or written. When you read or write, increment
+ /// pchNext by the number of bytes read or written.
+ ///
+ ///
+ /// -
+ /// The pchEndRead member points to 1 byte past the last valid byte in the buffer that can be read.
+ ///
+ /// -
+ /// The pchEndWrite member points to 1 byte past the last location in the buffer that can be written.
+ ///
+ ///
+ ///
+ /// After you read or write to the buffer and modify pchNext, do not call any multimedia file I/O functions except
+ /// mmioAdvance until you call the mmioSetInfo function. Call mmioSetInfo when you are finished directly accessing the buffer.
+ ///
+ ///
+ /// When you reach the end of the buffer specified by the pchEndRead or pchEndWrite member, call mmioAdvance to fill
+ /// the buffer from the disk or write the buffer to the disk. The mmioAdvance function updates the pchNext,
+ /// pchEndRead, and pchEndWrite members in the MMIOINFO structure for the file.
+ ///
+ ///
+ /// Before calling mmioAdvance or mmioSetInfo to flush a buffer to disk, set the MMIO_DIRTY flag in the dwFlags member of the
+ /// MMIOINFO structure for the file. Otherwise, the buffer will not be written to disk.
+ ///
+ ///
+ /// Do not decrement pchNext or modify any members in the MMIOINFO structure other than pchNext and dwFlags. Do
+ /// not set any flags in dwFlags except MMIO_DIRTY.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiogetinfo MMRESULT mmioGetInfo( HMMIO hmmio, LPMMIOINFO
+ // pmmioinfo, UINT fuInfo );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioGetInfo")]
+ public static extern MMRESULT mmioGetInfo(HMMIO hmmio, out MMIOINFO pmmioinfo, uint fuInfo = 0);
+
+ ///
+ /// The mmioInstallIOProc function installs or removes a custom I/O procedure. This function also locates an installed I/O
+ /// procedure, using its corresponding four-character code.
+ ///
+ ///
+ /// Four-character code identifying the I/O procedure to install, remove, or locate. All characters in this code should be uppercase.
+ ///
+ ///
+ /// Pointer to the I/O procedure to install. To remove or locate an I/O procedure, set this parameter to NULL. For more
+ /// information about the I/O procedure, see MMIOProc.
+ ///
+ ///
+ /// Flag indicating whether the I/O procedure is being installed, removed, or located. The following values are defined.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// MMIO_FINDPROC
+ /// Searches for the specified I/O procedure.
+ ///
+ /// -
+ /// MMIO_GLOBALPROC
+ ///
+ /// This flag is a modifier to the MMIO_INSTALLPROC flag and indicates the I/O procedure should be installed for global use. This
+ /// flag is ignored if MMIO_FINDPROC or MMIO_REMOVEPROC is specified.
+ ///
+ ///
+ /// -
+ /// MMIO_INSTALLPROC
+ /// Installs the specified I/O procedure.
+ ///
+ /// -
+ /// MMIO_REMOVEPROC
+ /// Removes the specified I/O procedure.
+ ///
+ ///
+ ///
+ /// Returns the address of the I/O procedure installed, removed, or located. Returns NULL if there is an error.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioinstallioproc LPMMIOPROC mmioInstallIOProc( FOURCC
+ // fccIOProc, LPMMIOPROC pIOProc, DWORD dwFlags );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioInstallIOProc")]
+ [return: MarshalAs(UnmanagedType.FunctionPtr)]
+ public static extern MMIOPROC mmioInstallIOProc(uint fccIOProc, [In, Optional] MMIOPROC pIOProc, MMIOINST dwFlags);
+
+ ///
+ ///
+ /// The mmioOpen function opens a file for unbuffered or buffered I/O; creates a file; deletes a file; or checks whether a
+ /// file exists. The file can be a standard file, a memory file, or an element of a custom storage system. The handle returned by
+ /// mmioOpen is not a standard file handle; do not use it with any file I/O functions other than multimedia file I/O functions.
+ ///
+ /// Note This function is deprecated. Applications should call CreateFile to create or open files.
+ ///
+ ///
+ ///
+ /// Pointer to a buffer that contains the name of the file. If no I/O procedure is specified to open the file, the file name
+ /// determines how the file is opened, as follows:
+ ///
+ ///
+ /// -
+ ///
+ /// If the file name does not contain a plus sign (+), it is assumed to be the name of a standard file (that is, a file whose type
+ /// is not HMMIO).
+ ///
+ ///
+ /// -
+ ///
+ /// If the file name is of the form EXAMPLE.EXT+ABC, the extension EXT is assumed to identify an installed I/O procedure which is
+ /// called to perform I/O on the file. For more information, see mmioInstallIOProc.
+ ///
+ ///
+ /// -
+ ///
+ /// If the file name is NULL and no I/O procedure is given, the adwInfo member of the MMIOINFO structure is assumed to
+ /// be the standard (non- HMMIO) file handle of a currently open file.
+ ///
+ ///
+ ///
+ /// The file name should not be longer than 128 characters, including the terminating NULL character.
+ /// When opening a memory file, set szFilename to NULL.
+ ///
+ ///
+ /// Pointer to an MMIOINFO structure containing extra parameters used by mmioOpen. Unless you are opening a memory file,
+ /// specifying the size of a buffer for buffered I/O, or specifying an uninstalled I/O procedure to open a file, this parameter
+ /// should be NULL. If this parameter is not NULL, all unused members of the MMIOINFO structure it references
+ /// must be set to zero, including the reserved members.
+ ///
+ ///
+ ///
+ /// Flags for the open operation. The MMIO_READ, MMIO_WRITE, and MMIO_READWRITE flags are mutually exclusive – only one should be
+ /// specified. The MMIO_COMPAT, MMIO_EXCLUSIVE, MMIO_DENYWRITE, MMIO_DENYREAD, and MMIO_DENYNONE flags are file-sharing flags. The
+ /// following values are defined.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// MMIO_ALLOCBUF
+ ///
+ /// Opens a file for buffered I/O. To allocate a buffer larger or smaller than the default buffer size (8K, defined as
+ /// MMIO_DEFAULTBUFFER), set the cchBuffer member of the MMIOINFO structure to the desired buffer size. If cchBuffer is zero, the
+ /// default buffer size is used. If you are providing your own I/O buffer, this flag should not be used.
+ ///
+ ///
+ /// -
+ /// MMIO_COMPAT
+ ///
+ /// Opens the file with compatibility mode, allowing any process on a given machine to open the file any number of times. If the
+ /// file has been opened with any of the other sharing modes, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_CREATE
+ ///
+ /// Creates a new file. If the file already exists, it is truncated to zero length. For memory files, this flag indicates the end of
+ /// the file is initially at the start of the buffer.
+ ///
+ ///
+ /// -
+ /// MMIO_DELETE
+ ///
+ /// Deletes a file. If this flag is specified, szFilename should not be NULL. The return value is TRUE (cast to HMMIO) if the file
+ /// was deleted successfully or FALSE otherwise. Do not call the mmioClose function for a file that has been deleted. If this flag
+ /// is specified, all other flags that open files are ignored.
+ ///
+ ///
+ /// -
+ /// MMIO_DENYNONE
+ ///
+ /// Opens the file without denying other processes read or write access to the file. If the file has been opened in compatibility
+ /// mode by any other process, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_DENYREAD
+ ///
+ /// Opens the file and denies other processes read access to the file. If the file has been opened in compatibility mode or for read
+ /// access by any other process, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_DENYWRITE
+ ///
+ /// Opens the file and denies other processes write access to the file. If the file has been opened in compatibility mode or for
+ /// write access by any other process, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_EXCLUSIVE
+ ///
+ /// Opens the file and denies other processes read and write access to the file. If the file has been opened in any other mode for
+ /// read or write access, even by the current process, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_EXIST
+ ///
+ /// Determines whether the specified file exists and creates a fully qualified file name from the path specified in szFilename. The
+ /// return value is TRUE (cast to HMMIO) if the qualification was successful and the file exists or FALSE otherwise. The file is not
+ /// opened, and the function does not return a valid multimedia file I/O file handle, so do not attempt to close the file.
+ ///
+ ///
+ /// -
+ /// MMIO_GETTEMP
+ ///
+ /// Creates a temporary file name, optionally using the parameters passed in szFilename. For example, you can specify "C:F" to
+ /// create a temporary file residing on drive C, starting with letter "F". The resulting file name is copied to the buffer pointed
+ /// to by szFilename. The buffer must be large enough to hold at least 128 characters. If the temporary file name was created
+ /// successfully, the return value is MMSYSERR_NOERROR (cast to HMMIO). Otherwise, the return value is MMIOERR_FILENOTFOUND
+ /// otherwise. The file is not opened, and the function does not return a valid multimedia file I/O file handle, so do not attempt
+ /// to close the file. This flag overrides all other flags.
+ ///
+ ///
+ /// -
+ /// MMIO_PARSE
+ ///
+ /// Creates a fully qualified file name from the path specified in szFilename. The fully qualified name is copied to the buffer
+ /// pointed to by szFilename. The buffer must be large enough to hold at least 128 characters. If the function succeeds, the return
+ /// value is TRUE (cast to HMMIO). Otherwise, the return value is FALSE. The file is not opened, and the function does not return a
+ /// valid multimedia file I/O file handle, so do not attempt to close the file. If this flag is specified, all flags that open files
+ /// are ignored.
+ ///
+ ///
+ /// -
+ /// MMIO_READ
+ /// Opens the file for reading only. This is the default if MMIO_WRITE and MMIO_READWRITE are not specified.
+ ///
+ /// -
+ /// MMIO_READWRITE
+ /// Opens the file for reading and writing.
+ ///
+ /// -
+ /// MMIO_WRITE
+ /// Opens the file for writing only.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns a handle of the opened file. If the file cannot be opened, the return value is NULL. If lpmmioinfo is not
+ /// NULL, the wErrorRet member of the MMIOINFO structure will contain one of the following error values.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_ACCESSDENIED
+ /// The file is protected and cannot be opened.
+ ///
+ /// -
+ /// MMIOERR_INVALIDFILE
+ /// Another failure condition occurred. This is the default error for an open-file failure.
+ ///
+ /// -
+ /// MMIOERR_NETWORKERROR
+ /// The network is not responding to the request to open a remote file.
+ ///
+ /// -
+ /// MMIOERR_PATHNOTFOUND
+ /// The directory specification is incorrect.
+ ///
+ /// -
+ /// MMIOERR_SHARINGVIOLATION
+ /// The file is being used by another application and is unavailable.
+ ///
+ /// -
+ /// MMIOERR_TOOMANYOPENFILES
+ /// The number of files simultaneously open is at a maximum level. The system has run out of available file handles.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If lpmmioinfo points to an MMIOINFO structure, initialize the members of the structure as follows. All unused members must be
+ /// set to zero, including reserved members.
+ ///
+ ///
+ /// -
+ ///
+ /// To request that a file be opened with an installed I/O procedure, set fccIOProc to the four-character code of the I/O
+ /// procedure, and set pIOProc to NULL.
+ ///
+ ///
+ /// -
+ ///
+ /// To request that a file be opened with an uninstalled I/O procedure, set IOProc to point to the I/O procedure, and set
+ /// fccIOProc to NULL.
+ ///
+ ///
+ /// -
+ ///
+ /// To request that mmioOpen determine which I/O procedure to use to open the file based on the file name contained in
+ /// szFilename, set fccIOProc and pIOProc to NULL. This is the default behavior if no MMIOINFO structure is specified.
+ ///
+ ///
+ /// -
+ ///
+ /// To open a memory file using an internally allocated and managed buffer, set pchBuffer to NULL, fccIOProc to
+ /// FOURCC_MEM, cchBuffer to the initial size of the buffer, and adwInfo to the incremental expansion size of the
+ /// buffer. This memory file will automatically be expanded in increments of the number of bytes specified in adwInfo when
+ /// necessary. Specify the MMIO_CREATE flag for the dwOpenFlags parameter to initially set the end of the file to be the beginning
+ /// of the buffer.
+ ///
+ ///
+ /// -
+ ///
+ /// To open a memory file using an application-supplied buffer, set pchBuffer to point to the memory buffer, fccIOProc
+ /// to FOURCC_MEM, cchBuffer to the size of the buffer, and adwInfo to the incremental expansion size of the buffer.
+ /// The expansion size in adwInfo should be nonzero only if pchBuffer is a pointer obtained by calling the GlobalAlloc
+ /// and GlobalLock functions; in this case, the GlobalReAlloc function will be called to expand the buffer. In other words, if
+ /// pchBuffer points to a local or global array or a block of memory in the local heap, adwInfo must be zero. Specify
+ /// the MMIO_CREATE flag for the dwOpenFlags parameter to initially set the end of the file to be the beginning of the buffer.
+ /// Otherwise, the entire block of memory is considered readable.
+ ///
+ ///
+ /// -
+ ///
+ /// To use a currently open standard file handle (that is, a file handle that does not have the HMMIO type) with multimedia
+ /// file I/O services, set fccIOProc to FOURCC_DOS, pchBuffer to NULL, and adwInfo to the standard file
+ /// handle. Offsets within the file will be relative to the beginning of the file and are not related to the position in the
+ /// standard file at the time mmioOpen is called; the initial multimedia file I/O offset will be the same as the offset in
+ /// the standard file when mmioOpen is called. To close the multimedia file I/O file handle without closing the standard file
+ /// handle, pass the MMIO_FHOPEN flag to mmioClose.
+ ///
+ ///
+ ///
+ ///
+ /// You must call mmioClose to close a file opened by using mmioOpen. Open files are not automatically closed when an
+ /// application exits.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioopen HMMIO mmioOpen( LPSTR pszFileName, LPMMIOINFO
+ // pmmioinfo, DWORD fdwOpen );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioOpen")]
+ public static extern HMMIO mmioOpen([In, Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder pszFileName, ref MMIOINFO pmmioinfo, MMIO fdwOpen);
+
+ ///
+ ///
+ /// The mmioOpen function opens a file for unbuffered or buffered I/O; creates a file; deletes a file; or checks whether a
+ /// file exists. The file can be a standard file, a memory file, or an element of a custom storage system. The handle returned by
+ /// mmioOpen is not a standard file handle; do not use it with any file I/O functions other than multimedia file I/O functions.
+ ///
+ /// Note This function is deprecated. Applications should call CreateFile to create or open files.
+ ///
+ ///
+ ///
+ /// Pointer to a buffer that contains the name of the file. If no I/O procedure is specified to open the file, the file name
+ /// determines how the file is opened, as follows:
+ ///
+ ///
+ /// -
+ ///
+ /// If the file name does not contain a plus sign (+), it is assumed to be the name of a standard file (that is, a file whose type
+ /// is not HMMIO).
+ ///
+ ///
+ /// -
+ ///
+ /// If the file name is of the form EXAMPLE.EXT+ABC, the extension EXT is assumed to identify an installed I/O procedure which is
+ /// called to perform I/O on the file. For more information, see mmioInstallIOProc.
+ ///
+ ///
+ /// -
+ ///
+ /// If the file name is NULL and no I/O procedure is given, the adwInfo member of the MMIOINFO structure is assumed to
+ /// be the standard (non- HMMIO) file handle of a currently open file.
+ ///
+ ///
+ ///
+ /// The file name should not be longer than 128 characters, including the terminating NULL character.
+ /// When opening a memory file, set szFilename to NULL.
+ ///
+ ///
+ /// Pointer to an MMIOINFO structure containing extra parameters used by mmioOpen. Unless you are opening a memory file,
+ /// specifying the size of a buffer for buffered I/O, or specifying an uninstalled I/O procedure to open a file, this parameter
+ /// should be NULL. If this parameter is not NULL, all unused members of the MMIOINFO structure it references
+ /// must be set to zero, including the reserved members.
+ ///
+ ///
+ ///
+ /// Flags for the open operation. The MMIO_READ, MMIO_WRITE, and MMIO_READWRITE flags are mutually exclusive – only one should be
+ /// specified. The MMIO_COMPAT, MMIO_EXCLUSIVE, MMIO_DENYWRITE, MMIO_DENYREAD, and MMIO_DENYNONE flags are file-sharing flags. The
+ /// following values are defined.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// MMIO_ALLOCBUF
+ ///
+ /// Opens a file for buffered I/O. To allocate a buffer larger or smaller than the default buffer size (8K, defined as
+ /// MMIO_DEFAULTBUFFER), set the cchBuffer member of the MMIOINFO structure to the desired buffer size. If cchBuffer is zero, the
+ /// default buffer size is used. If you are providing your own I/O buffer, this flag should not be used.
+ ///
+ ///
+ /// -
+ /// MMIO_COMPAT
+ ///
+ /// Opens the file with compatibility mode, allowing any process on a given machine to open the file any number of times. If the
+ /// file has been opened with any of the other sharing modes, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_CREATE
+ ///
+ /// Creates a new file. If the file already exists, it is truncated to zero length. For memory files, this flag indicates the end of
+ /// the file is initially at the start of the buffer.
+ ///
+ ///
+ /// -
+ /// MMIO_DELETE
+ ///
+ /// Deletes a file. If this flag is specified, szFilename should not be NULL. The return value is TRUE (cast to HMMIO) if the file
+ /// was deleted successfully or FALSE otherwise. Do not call the mmioClose function for a file that has been deleted. If this flag
+ /// is specified, all other flags that open files are ignored.
+ ///
+ ///
+ /// -
+ /// MMIO_DENYNONE
+ ///
+ /// Opens the file without denying other processes read or write access to the file. If the file has been opened in compatibility
+ /// mode by any other process, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_DENYREAD
+ ///
+ /// Opens the file and denies other processes read access to the file. If the file has been opened in compatibility mode or for read
+ /// access by any other process, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_DENYWRITE
+ ///
+ /// Opens the file and denies other processes write access to the file. If the file has been opened in compatibility mode or for
+ /// write access by any other process, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_EXCLUSIVE
+ ///
+ /// Opens the file and denies other processes read and write access to the file. If the file has been opened in any other mode for
+ /// read or write access, even by the current process, mmioOpen fails.
+ ///
+ ///
+ /// -
+ /// MMIO_EXIST
+ ///
+ /// Determines whether the specified file exists and creates a fully qualified file name from the path specified in szFilename. The
+ /// return value is TRUE (cast to HMMIO) if the qualification was successful and the file exists or FALSE otherwise. The file is not
+ /// opened, and the function does not return a valid multimedia file I/O file handle, so do not attempt to close the file.
+ ///
+ ///
+ /// -
+ /// MMIO_GETTEMP
+ ///
+ /// Creates a temporary file name, optionally using the parameters passed in szFilename. For example, you can specify "C:F" to
+ /// create a temporary file residing on drive C, starting with letter "F". The resulting file name is copied to the buffer pointed
+ /// to by szFilename. The buffer must be large enough to hold at least 128 characters. If the temporary file name was created
+ /// successfully, the return value is MMSYSERR_NOERROR (cast to HMMIO). Otherwise, the return value is MMIOERR_FILENOTFOUND
+ /// otherwise. The file is not opened, and the function does not return a valid multimedia file I/O file handle, so do not attempt
+ /// to close the file. This flag overrides all other flags.
+ ///
+ ///
+ /// -
+ /// MMIO_PARSE
+ ///
+ /// Creates a fully qualified file name from the path specified in szFilename. The fully qualified name is copied to the buffer
+ /// pointed to by szFilename. The buffer must be large enough to hold at least 128 characters. If the function succeeds, the return
+ /// value is TRUE (cast to HMMIO). Otherwise, the return value is FALSE. The file is not opened, and the function does not return a
+ /// valid multimedia file I/O file handle, so do not attempt to close the file. If this flag is specified, all flags that open files
+ /// are ignored.
+ ///
+ ///
+ /// -
+ /// MMIO_READ
+ /// Opens the file for reading only. This is the default if MMIO_WRITE and MMIO_READWRITE are not specified.
+ ///
+ /// -
+ /// MMIO_READWRITE
+ /// Opens the file for reading and writing.
+ ///
+ /// -
+ /// MMIO_WRITE
+ /// Opens the file for writing only.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns a handle of the opened file. If the file cannot be opened, the return value is NULL. If lpmmioinfo is not
+ /// NULL, the wErrorRet member of the MMIOINFO structure will contain one of the following error values.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_ACCESSDENIED
+ /// The file is protected and cannot be opened.
+ ///
+ /// -
+ /// MMIOERR_INVALIDFILE
+ /// Another failure condition occurred. This is the default error for an open-file failure.
+ ///
+ /// -
+ /// MMIOERR_NETWORKERROR
+ /// The network is not responding to the request to open a remote file.
+ ///
+ /// -
+ /// MMIOERR_PATHNOTFOUND
+ /// The directory specification is incorrect.
+ ///
+ /// -
+ /// MMIOERR_SHARINGVIOLATION
+ /// The file is being used by another application and is unavailable.
+ ///
+ /// -
+ /// MMIOERR_TOOMANYOPENFILES
+ /// The number of files simultaneously open is at a maximum level. The system has run out of available file handles.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If lpmmioinfo points to an MMIOINFO structure, initialize the members of the structure as follows. All unused members must be
+ /// set to zero, including reserved members.
+ ///
+ ///
+ /// -
+ ///
+ /// To request that a file be opened with an installed I/O procedure, set fccIOProc to the four-character code of the I/O
+ /// procedure, and set pIOProc to NULL.
+ ///
+ ///
+ /// -
+ ///
+ /// To request that a file be opened with an uninstalled I/O procedure, set IOProc to point to the I/O procedure, and set
+ /// fccIOProc to NULL.
+ ///
+ ///
+ /// -
+ ///
+ /// To request that mmioOpen determine which I/O procedure to use to open the file based on the file name contained in
+ /// szFilename, set fccIOProc and pIOProc to NULL. This is the default behavior if no MMIOINFO structure is specified.
+ ///
+ ///
+ /// -
+ ///
+ /// To open a memory file using an internally allocated and managed buffer, set pchBuffer to NULL, fccIOProc to
+ /// FOURCC_MEM, cchBuffer to the initial size of the buffer, and adwInfo to the incremental expansion size of the
+ /// buffer. This memory file will automatically be expanded in increments of the number of bytes specified in adwInfo when
+ /// necessary. Specify the MMIO_CREATE flag for the dwOpenFlags parameter to initially set the end of the file to be the beginning
+ /// of the buffer.
+ ///
+ ///
+ /// -
+ ///
+ /// To open a memory file using an application-supplied buffer, set pchBuffer to point to the memory buffer, fccIOProc
+ /// to FOURCC_MEM, cchBuffer to the size of the buffer, and adwInfo to the incremental expansion size of the buffer.
+ /// The expansion size in adwInfo should be nonzero only if pchBuffer is a pointer obtained by calling the GlobalAlloc
+ /// and GlobalLock functions; in this case, the GlobalReAlloc function will be called to expand the buffer. In other words, if
+ /// pchBuffer points to a local or global array or a block of memory in the local heap, adwInfo must be zero. Specify
+ /// the MMIO_CREATE flag for the dwOpenFlags parameter to initially set the end of the file to be the beginning of the buffer.
+ /// Otherwise, the entire block of memory is considered readable.
+ ///
+ ///
+ /// -
+ ///
+ /// To use a currently open standard file handle (that is, a file handle that does not have the HMMIO type) with multimedia
+ /// file I/O services, set fccIOProc to FOURCC_DOS, pchBuffer to NULL, and adwInfo to the standard file
+ /// handle. Offsets within the file will be relative to the beginning of the file and are not related to the position in the
+ /// standard file at the time mmioOpen is called; the initial multimedia file I/O offset will be the same as the offset in
+ /// the standard file when mmioOpen is called. To close the multimedia file I/O file handle without closing the standard file
+ /// handle, pass the MMIO_FHOPEN flag to mmioClose.
+ ///
+ ///
+ ///
+ ///
+ /// You must call mmioClose to close a file opened by using mmioOpen. Open files are not automatically closed when an
+ /// application exits.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioopen HMMIO mmioOpen( LPSTR pszFileName, LPMMIOINFO
+ // pmmioinfo, DWORD fdwOpen );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioOpen")]
+ public static extern HMMIO mmioOpen([In, Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder pszFileName, [In, Optional] IntPtr pmmioinfo, MMIO fdwOpen);
+
+ /// The mmioRead function reads a specified number of bytes from a file opened by using the mmioOpen function.
+ /// File handle of the file to be read.
+ /// Pointer to a buffer to contain the data read from the file.
+ /// Number of bytes to read from the file.
+ ///
+ /// Returns the number of bytes actually read. If the end of the file has been reached and no more bytes can be read, the return
+ /// value is 0. If there is an error reading from the file, the return value is –1.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioread LONG mmioRead( HMMIO hmmio, HPSTR pch, LONG cch );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioRead")]
+ public static extern int mmioRead(HMMIO hmmio, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] pch, int cch);
+
+ /// The mmioRename function renames the specified file.
+ /// Pointer to a string containing the file name of the file to rename.
+ /// Pointer to a string containing the new file name.
+ ///
+ /// Pointer to an MMIOINFO structure containing extra parameters used by mmioRename. If this parameter is not NULL,
+ /// all unused members of the MMIOINFO structure it references must be set to zero, including the reserved members.
+ ///
+ /// Flags for the rename operation. This parameter should be set to zero.
+ ///
+ /// Returns zero if the file was renamed. Otherwise, returns an error code returned from mmioRename or from the I/O procedure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiorename MMRESULT mmioRename( LPCSTR pszFileName,
+ // LPCSTR pszNewFileName, const MMIOINFO *pmmioinfo, DWORD fdwRename );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioRename")]
+ public static extern MMRESULT mmioRename([MarshalAs(UnmanagedType.LPTStr)] string pszFileName, [MarshalAs(UnmanagedType.LPTStr)] string pszNewFileName, in MMIOINFO pmmioinfo, uint fdwRename = 0);
+
+ /// The mmioRename function renames the specified file.
+ /// Pointer to a string containing the file name of the file to rename.
+ /// Pointer to a string containing the new file name.
+ ///
+ /// Pointer to an MMIOINFO structure containing extra parameters used by mmioRename. If this parameter is not NULL,
+ /// all unused members of the MMIOINFO structure it references must be set to zero, including the reserved members.
+ ///
+ /// Flags for the rename operation. This parameter should be set to zero.
+ ///
+ /// Returns zero if the file was renamed. Otherwise, returns an error code returned from mmioRename or from the I/O procedure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiorename MMRESULT mmioRename( LPCSTR pszFileName,
+ // LPCSTR pszNewFileName, const MMIOINFO *pmmioinfo, DWORD fdwRename );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioRename")]
+ public static extern MMRESULT mmioRename([MarshalAs(UnmanagedType.LPTStr)] string pszFileName, [MarshalAs(UnmanagedType.LPTStr)] string pszNewFileName, [In, Optional] IntPtr pmmioinfo, uint fdwRename = 0);
+
+ /// The mmioSeek function changes the current file position in a file opened by using the mmioOpen function.
+ /// File handle of the file to seek in.
+ /// Offset to change the file position.
+ ///
+ /// Flags indicating how the offset specified by lOffset is interpreted. The following values are defined:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// SEEK_CUR
+ /// Seeks to lOffset bytes from the current file position.
+ ///
+ /// -
+ /// SEEK_END
+ /// Seeks to lOffset bytes from the end of the file.
+ ///
+ /// -
+ /// SEEK_SET
+ /// Seeks to lOffset bytes from the beginning of the file.
+ ///
+ ///
+ ///
+ ///
+ /// Returns the new file position, in bytes, relative to the beginning of the file. If there is an error, the return value is –1.
+ ///
+ ///
+ ///
+ /// Seeking to an invalid location in the file, such as past the end of the file, might not cause mmioSeek to return an
+ /// error, but it might cause subsequent I/O operations on the file to fail.
+ ///
+ /// To locate the end of a file, call mmioSeek with lOffset set to zero and iOrigin set to SEEK_END.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmioseek LONG mmioSeek( HMMIO hmmio, LONG lOffset, int
+ // iOrigin );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioSeek")]
+ public static extern int mmioSeek(HMMIO hmmio, int lOffset, int iOrigin);
+
+ /// The mmioSendMessage function sends a message to the I/O procedure associated with the specified file.
+ /// File handle for a file opened by using the mmioOpen function.
+ /// Message to send to the I/O procedure.
+ /// Parameter for the message.
+ /// Parameter for the message.
+ ///
+ /// Returns a value that corresponds to the message. If the I/O procedure does not recognize the message, the return value should be zero.
+ ///
+ ///
+ /// Use this function to send custom user-defined messages. Do not use it to send the MMIOM_OPEN, MMIOM_CLOSE, MMIOM_READ,
+ /// MMIOM_WRITE, MMIOM_WRITEFLUSH, or MMIOM_SEEK messages. Define custom messages to be greater than or equal to the MMIOM_USER constant.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiosendmessage LRESULT mmioSendMessage( HMMIO hmmio,
+ // UINT uMsg, LPARAM lParam1, LPARAM lParam2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioSendMessage")]
+ public static extern IntPtr mmioSendMessage(HMMIO hmmio, uint uMsg, IntPtr lParam1, IntPtr lParam2);
+
+ ///
+ /// The mmioSetBuffer function enables or disables buffered I/O, or changes the buffer or buffer size for a file opened by
+ /// using the mmioOpen function.
+ ///
+ /// File handle of the file.
+ ///
+ /// Pointer to an application-defined buffer to use for buffered I/O. If this parameter is NULL, mmioSetBuffer
+ /// allocates an internal buffer for buffered I/O.
+ ///
+ ///
+ /// Size, in characters, of the application-defined buffer, or the size of the buffer for mmioSetBuffer to allocate.
+ ///
+ /// Reserved; must be zero.
+ ///
+ ///
+ /// Returns zero if successful or an error otherwise. If an error occurs, the file handle remains valid. The following values are defined.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// MMIOERR_CANNOTWRITE
+ /// The contents of the old buffer could not be written to disk, so the operation was aborted.
+ ///
+ /// -
+ /// MMIOERR_OUTOFMEMORY
+ /// The new buffer could not be allocated, probably due to a lack of available memory.
+ ///
+ ///
+ ///
+ ///
+ /// To enable buffering using an internal buffer, set pchBuffer to NULL and cchBuffer to the desired buffer size.
+ /// To supply your own buffer, set pchBuffer to point to the buffer, and set cchBuffer to the size of the buffer.
+ /// To disable buffered I/O, set pchBuffer to NULL and cchBuffer to zero.
+ ///
+ /// If buffered I/O is already enabled using an internal buffer, you can reallocate the buffer to a different size by setting
+ /// pchBuffer to NULL and cchBuffer to the new buffer size. The contents of the buffer can be changed after resizing.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiosetbuffer MMRESULT mmioSetBuffer( HMMIO hmmio, LPSTR
+ // pchBuffer, LONG cchBuffer, UINT fuBuffer );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioSetBuffer")]
+ public static extern MMRESULT mmioSetBuffer(HMMIO hmmio, [Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder pchBuffer, int cchBuffer, uint fuBuffer = 0);
+
+ ///
+ /// The mmioSetInfo function updates the information retrieved by the mmioGetInfo function about a file opened by using the
+ /// mmioOpen function. Use this function to terminate direct buffer access of a file opened for buffered I/O.
+ ///
+ /// File handle of the file.
+ /// Pointer to an MMIOINFO structure filled with information by the mmioGetInfo function.
+ /// Reserved; must be zero.
+ /// Returns zero if successful or an error otherwise.
+ ///
+ /// If you have written to the file I/O buffer, set the MMIO_DIRTY flag in the dwFlags member of the MMIOINFO structure
+ /// before calling mmioSetInfo to terminate direct buffer access. Otherwise, the buffer will not get flushed to disk.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiosetinfo MMRESULT mmioSetInfo( HMMIO hmmio,
+ // LPCMMIOINFO pmmioinfo, UINT fuInfo );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioSetInfo")]
+ public static extern MMRESULT mmioSetInfo(HMMIO hmmio, in MMIOINFO pmmioinfo, uint fuInfo = 0);
+
+ /// The mmioStringToFOURCC function converts a null-terminated string to a four-character code.
+ /// Pointer to a null-terminated string to convert to a four-character code.
+ ///
+ /// Flags for the conversion. The following value is defined:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// MMIO_TOUPPER
+ /// Converts all characters to uppercase.
+ ///
+ ///
+ ///
+ /// Returns the four-character code created from the given string.
+ ///
+ /// This function copies the string to a four-character code and pads it with space characters or truncates it if necessary. It does
+ /// not check whether the code it returns is valid.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiostringtofourcc FOURCC mmioStringToFOURCC( LPCSTR sz,
+ // UINT uFlags );
+ [DllImport(Lib_Winmm, SetLastError = false, CharSet = CharSet.Auto)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioStringToFOURCC")]
+ public static extern uint mmioStringToFOURCC([MarshalAs(UnmanagedType.LPTStr)] string sz, MMIOCONV uFlags);
+
+ /// The mmioWrite function writes a specified number of bytes to a file opened by using the mmioOpen function.
+ /// File handle of the file.
+ /// Pointer to the buffer to be written to the file.
+ /// Number of bytes to write to the file.
+ /// Returns the number of bytes actually written. If there is an error writing to the file, the return value is -1.
+ /// The current file position is incremented by the number of bytes written.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-mmiowrite LONG mmioWrite( HMMIO hmmio, const char _huge
+ // *pch, LONG cch );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.mmioWrite")]
+ public static extern int mmioWrite(HMMIO hmmio, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] pch, int cch);
+
+ ///
+ /// Opens an instance of an installable driver and initializes the instance using either the driver's default settings or a
+ /// driver-specific value.
+ ///
+ ///
+ /// Address of a null-terminated, wide-character string that specifies the filename of an installable driver or the name of a
+ /// registry value associated with the installable driver. (This value must have been previously set when the driver was installed.)
+ ///
+ ///
+ /// Address of a null-terminated, wide-character string that specifies the name of the registry key containing the registry value
+ /// given by the lpDriverName parameter. If lpSectionName is NULL, the registry key is assumed to be Drivers32.
+ ///
+ ///
+ /// 32-bit driver-specific value. This value is passed as the lParam2 parameter to the DriverProc function of the installable driver.
+ ///
+ /// Returns the handle of the installable driver instance if successful or NULL otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-opendriver HDRVR OpenDriver( LPCWSTR szDriverName,
+ // LPCWSTR szSectionName, LPARAM lParam2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.OpenDriver")]
+ public static extern SafeHDRVR OpenDriver([MarshalAs(UnmanagedType.LPWStr)] string szDriverName, [Optional, MarshalAs(UnmanagedType.LPWStr)] string szSectionName, [In, Optional] IntPtr lParam2);
+
+ /// Sends the specified message to the installable driver.
+ ///
+ /// Handle of the installable driver instance. The handle must been previously created by using the OpenDriver function.
+ ///
+ ///
+ /// Driver message value. It can be a custom message value or one of these standard message values.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// DRV_QUERYCONFIGURE
+ ///
+ /// Queries an installable driver about whether it supports the DRV_CONFIGURE message and can display a configuration dialog box.
+ ///
+ ///
+ /// -
+ /// DRV_CONFIGURE
+ ///
+ /// Notifies an installable driver that it should display a configuration dialog box. (This message should only be sent if the
+ /// driver returns a nonzero value when the DRV_QUERYCONFIGURE message is processed.)
+ ///
+ ///
+ /// -
+ /// DRV_INSTALL
+ /// Notifies an installable driver that it has been successfully installed.
+ ///
+ /// -
+ /// DRV_REMOVE
+ /// Notifies an installable driver that it is about to be removed from the system.
+ ///
+ ///
+ ///
+ /// 32-bit message-dependent information.
+ /// 32-bit message-dependent information.
+ /// Returns nonzero if successful or zero otherwise.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-senddrivermessage LRESULT SendDriverMessage( HDRVR
+ // hDriver, UINT message, LPARAM lParam1, LPARAM lParam2 );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.SendDriverMessage")]
+ public static extern IntPtr SendDriverMessage(HDRVR hDriver, DRV message, IntPtr lParam1, IntPtr lParam2);
+
+ /// Opens the specified sound event.
+ /// The name of the sound event.
+ /// The application associated with the sound event.
+ /// Flags for playing the sound. The following values are defined.
+ /// Receives the handle to the sound.
+ /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/nf-mmiscapi-sndopensound LONG sndOpenSound( LPCWSTR EventName,
+ // LPCWSTR AppName, INT32 Flags, PHANDLE FileHandle );
+ [DllImport(Lib_Winmm, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NF:mmiscapi.sndOpenSound")]
+ public static extern int sndOpenSound([MarshalAs(UnmanagedType.LPWStr)] string EventName, [MarshalAs(UnmanagedType.LPWStr)] string AppName, int Flags, out IntPtr FileHandle);
+
+ /// Contains the registry key and value names associated with the installable driver.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/ns-mmiscapi-drvconfiginfo typedef struct tagDRVCONFIGINFO { DWORD
+ // dwDCISize; LPCWSTR lpszDCISectionName; LPCWSTR lpszDCIAliasName; } DRVCONFIGINFO, *PDRVCONFIGINFO, *NPDRVCONFIGINFO, *LPDRVCONFIGINFO;
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NS:mmiscapi.tagDRVCONFIGINFO")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct DRVCONFIGINFO
+ {
+ /// Size of the structure, in bytes.
+ public uint dwDCISize;
+
+ ///
+ /// Address of a null-terminated, wide-character string specifying the name of the registry key associated with the driver.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string lpszDCISectionName;
+
+ ///
+ /// Address of a null-terminated, wide-character string specifying the name of the registry value associated with the driver.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string lpszDCIAliasName;
+ }
+
+ /// Provides a handle to an installable driver.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HDRVR : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HDRVR(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HDRVR NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HDRVR h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HDRVR(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HDRVR h1, HDRVR h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HDRVR h1, HDRVR h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HDRVR h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// Provides a handle to a MMIO device.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HMMIO : IHandle
+ {
+ private readonly IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HMMIO(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HMMIO NULL => new(IntPtr.Zero);
+
+ /// Gets a value indicating whether this instance is a null handle.
+ public bool IsNull => handle == IntPtr.Zero;
+
+ /// Performs an explicit conversion from to .
+ /// The handle.
+ /// The result of the conversion.
+ public static explicit operator IntPtr(HMMIO h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HMMIO(IntPtr h) => new(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HMMIO h1, HMMIO h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HMMIO h1, HMMIO h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HMMIO h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// The MMCKINFO structure contains information about a chunk in a RIFF file.
+ // https://docs.microsoft.com/en-us/windows/win32/api/mmiscapi/ns-mmiscapi-mmckinfo typedef struct _MMCKINFO { FOURCC ckid; DWORD
+ // cksize; FOURCC fccType; DWORD dwDataOffset; DWORD dwFlags; } MMCKINFO, *PMMCKINFO, *NPMMCKINFO, *LPMMCKINFO;
+ [PInvokeData("mmiscapi.h", MSDNShortId = "NS:mmiscapi._MMCKINFO")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct MMCKINFO
+ {
+ /// Chunk identifier.
+ public uint ckid;
+
+ ///
+ /// Size, in bytes, of the data member of the chunk. The size of the data member does not include the 4-byte chunk identifier,
+ /// the 4-byte chunk size, or the optional pad byte at the end of the data member.
+ ///
+ public uint cksize;
+
+ /// Form type for "RIFF" chunks or the list type for "LIST" chunks.
+ public uint fccType;
+
+ /// File offset of the beginning of the chunk's data member, relative to the beginning of the file.
+ public uint dwDataOffset;
+
+ ///
+ /// Flags specifying additional information about the chunk. It can be zero or the following flag:
+ ///
+ ///
+ /// Name
+ /// Description
+ ///
+ /// -
+ /// MMIO_DIRTY
+ ///
+ /// The length of the chunk might have changed and should be updated by the mmioAscend function. This flag is set when a chunk
+ /// is created by using the mmioCreateChunk function.
+ ///
+ ///
+ ///
+ ///
+ public MMIO dwFlags;
+ }
+
+ /// The MMIOINFO structure contains the current state of a file opened by using the mmioOpen function.
+ // https://docs.microsoft.com/en-us/previous-versions/dd757322(v=vs.85) typedef struct { DWORD dwFlags; FOURCC fccIOProc; LPMMIOPROC
+ // pIOProc; UINT wErrorRet; HTASK hTask; LONG cchBuffer; HPSTR pchBuffer; HPSTR pchNext; HPSTR pchEndRead; HPSTR pchEndWrite; LONG
+ // lBufOffset; LONG lDiskOffset; DWORD adwInfo[4]; DWORD dwReserved1; DWORD dwReserved2; HMMIO hmmio; } MMIOINFO;
+ [PInvokeData("Mmsystem.h")]
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
+ public struct MMIOINFO
+ {
+ /// Flags specifying how a file was opened.
+ public MMIO dwFlags;
+
+ ///
+ /// Four-character code identifying the file's I/O procedure. If the I/O procedure is not an installed I/O procedure, this
+ /// member is NULL.
+ ///
+ public uint fccIOProc;
+
+ /// Pointer to file's IO procedure.
+ [MarshalAs(UnmanagedType.FunctionPtr)]
+ public MMIOPROC pIOProc;
+
+ ///
+ /// Extended error value from the mmioOpen function if it returns NULL. This member is not used to return extended error
+ /// information from any other functions.
+ ///
+ public uint wErrorRet;
+
+ ///
+ /// Handle to a local I/O procedure. Media Control Interface (MCI) devices that perform file I/O in the background and need an
+ /// I/O procedure can locate a local I/O procedure with this handle.
+ ///
+ public HTASK hTask;
+
+ /// Size, in bytes, of the file's I/O buffer. If the file does not have an I/O buffer, this member is zero.
+ public int cchBuffer;
+
+ /// Pointer to the file's I/O buffer. If the file is unbuffered, this member is NULL.
+ public StrPtrAnsi pchBuffer;
+
+ ///
+ /// Pointer to the next location in the I/O buffer to be read or written. If no more bytes can be read without calling the
+ /// mmioAdvance or mmioRead function, this member points to the pchEndRead member. If no more bytes can be written without
+ /// calling the mmioAdvance or mmioWrite function, this member points to the pchEndWrite member.
+ ///
+ public StrPtrAnsi pchNext;
+
+ /// Pointer to the location that is 1 byte past the last location in the buffer that can be read.
+ public StrPtrAnsi pchEndRead;
+
+ /// Pointer to the location that is 1 byte past the last location in the buffer that can be written.
+ public StrPtrAnsi pchEndWrite;
+
+ /// Reserved.
+ public int lBufOffset;
+
+ ///
+ /// Current file position, which is an offset, in bytes, from the beginning of the file. I/O procedures are responsible for
+ /// maintaining this member.
+ ///
+ public int lDiskOffset;
+
+ ///
+ /// State information maintained by the I/O procedure. I/O procedures can also use these members to transfer information from
+ /// the application to the I/O procedure when the application opens a file.
+ ///
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
+ public uint[] adwInfo;
+
+ /// Reserved.
+ public uint dwReserved1;
+
+ /// Reserved.
+ public uint dwReserved2;
+
+ ///
+ /// Handle to the open file, as returned by the mmioOpen function. I/O procedures can use this handle when calling other
+ /// multimedia file I/O functions.
+ ///
+ public HMMIO hmmio;
+ }
+
+ /// Provides a for that is disposed using .
+ public class SafeHDRVR : SafeHANDLE
+ {
+ /// Initializes a new instance of the class and assigns an existing handle.
+ /// An object that represents the pre-existing handle to use.
+ ///
+ /// to reliably release the handle during the finalization phase; otherwise, (not recommended).
+ ///
+ public SafeHDRVR(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
+
+ /// Initializes a new instance of the class.
+ private SafeHDRVR() : base() { }
+
+ /// Performs an implicit conversion from to .
+ /// The safe handle instance.
+ /// The result of the conversion.
+ public static implicit operator HDRVR(SafeHDRVR h) => h.handle;
+
+ ///
+ protected override bool InternalReleaseHandle() => CloseDriver(handle) != default;
+ }
+ }
+}
\ No newline at end of file