Using a Device Exclusively

There are times when an application must retain control of the physical resource, such as the during the duration of a recording operation or when the application needs to establish specific settings for the device context. The application can retain control by not specifying the shareable flag with the open request or by setting the MCI_EXCLUSIVE flag of the MCI_ACQUIREDEVICE message. When a device has been acquired for exclusive use, other applications cannot acquire the device until the application using the device closes it or releases it from exclusive use with the MCI_RELEASEDEVICE message. When an application releases a device from exclusive use, it does not lose use of the device until another application acquires it.

When an application needs to acquire a device context for exclusive use without acquiring the entire device resource, the application can set the MCI_EXCLUSIVE_INSTANCE flag of the MCI_ACQUIREDEVICE message. This flag prevents the device context from being made inactive unless the application using the device issues the MCI_CLOSE or MCI_RELEASEDEVICE message.

The MCI_EXCLUSIVE_INSTANCE and MCI_EXCLUSIVE flags are mutually exclusive. An instance can be in one of three sharing states:

Using the MCI_EXCLUSIVE_INSTANCE flag places an instance in an instance-exclusive sharing state. Using the MCI_EXCLUSIVE flag places an instance in a device-exclusive sharing state. The MCI_RELEASEDEVICE message places an instance in a fully shareable state.


[Back: Getting Control of a Shared Device]
[Next: Device Groups]