Standard Driver Messages

Every user-mode driver must export a DriverProc function. Each DriverProc function must recognize a set of standard driver messages, which are defined in mmsystem.h. A driver receives the following standard messages, in the order listed, when an application uses the driver to perform input or output operations.

Message Operation Performed by Driver
DRV_LOAD Performs post-load operations.
DRV_ENABLE No operations performed under Windows NT.
DRV_OPEN Opens a driver instance.
DRV_CLOSE Closes a driver instance.
DRV_DISABLE No operations performed under Windows NT.
DRV_FREE Performs pre-unload operations.

Additionally, a driver can receive the following standard messages, which are typically sent from a Control Panel application during installation and configuration operations.

Message Operation Performed by Driver
DRV_INSTALL Installs the kernel-mode driver.
DRV_PNPINSTALL Installs a kernel-mode driver, using Plug and Play configuration information.
DRV_CONFIGURE Obtains configuration parameters.
DRV_QUERYCONFIGURE Indicates whether configuration parameters can be modified.

Although applications can send standard driver messages directly by calling SendDriverMessage, described in the Win32 SDK, typically they do not. Instead, they call functions provided by higher level multimedia APIs. These APIs in turn act as clients to the user-mode drivers and send messages by:

·Calling SendDriverMessage, to directly send any of the standard messages.

·Calling OpenDriver, described in the Win32 SDK. This function calls SendDriverMessage to send DRV_LOAD and DRV_ENABLE messages, if the driver has not been previously loaded, and then to send DRV_OPEN.

·Calling CloseDriver, described in the Win32 SDK. This function calls SendDriverMessage to send DRV_CLOSE and, if there are no other open instances of the driver, to also send DRV_DISABLE and DRV_FREE.

Besides supporting the standard driver messages, a user-mode multimedia driver’s DriverProc function generally also supports a set of customized driver messages.