Responding to the MCI_OPEN_SHAREABLE Flag

The MCI_OPEN_SHAREABLE flag requests that your device driver allow itself to be shared. For simple devices, this lets multiple applications have unrestricted access to your device driver. As a shared device, your device driver needs to create only one context for the mode and position of the MCI device for all the applications using it. The shared context lets each application change the mode and position of the MCI device. MCI will create a unique device ID for each shared instance of the device driver.

If your simple device cannot be shared, fail the open by returning MCIERR_UNSUPPORTED_FUNCTION. If your device driver is initially opened as shareable, return MCIERR_MUST_USE_SHAREABLE to fail any subsequent opens without the MCI_OPEN_SHAREABLE flag. If your device driver is initially opened as nonshareable, fail any subsequent opens by returning MCIERR_MUST_USE_SHAREABLE.

For compound devices, the MCI_OPEN_SHAREABLE flag applies to the device element. (Compound device drivers opened without a device element should ignore the MCI_OPEN_SHAREABLE flag.) A shared element lets multiple applications access the same context for the file element. All applications accessing the shared context have equal control over the element. If your compound device driver cannot support a shared element context, fail the open by returning MCIERR_UNSUPPORTED_FUNCTION. (The compound device drivers shipped with Windows do not support MCI_OPEN_SHAREABLE.)

If an element of your device driver is initially opened as a shared context, return MCIERR_MUST_USE_SHAREABLE to fail subsequent opens of that element context that do not include the MCI_OPEN_SHAREABLE flag. If an element context is initially opened as nonshareable, fail any subsequent opens with MCIERR_MUST_USE_SHAREABLE.

Your device driver might also let applications open a single device element (file) multiple times without using the MCI_OPEN_SHAREABLE flag. In this case, your device driver should treat each instance of the device element as a totally separate device element. You device driver should maintain separate position and status information for each instance.