MCI_RELEASEDEVICE
Appearance
This message is sent to release the exclusive use of physical device resources by a group or device instance. Releasing a device does not always cause the device to be passed to another application; ownership is only changed when the MCI_ACQUIREDEVICE message is used, or if another application opens or closes the device.
Syntax
param1 ULONG ulParam1; /* Message flags. */ param2 PMCI_GENERIC_PARMS pParam2; /* Pointer to the MCI_GENERIC_PARMS structure. */
Parameters
- ulParam1 (ULONG) - input
- The following flags can be used:
- MCI_NOTIFY Posts a notification message when the action completes.
- MCI_WAIT Does not return control until the action is completed.
- MCI_RETURN_RESOURCE Releases a device instance from the active state and makes the next available inactive device instance active. The device instance will not be made active again unless MCI_ACQUIREDEVICE is issued for this instance, or no other application is using the device. If the instance is already inactive, this flag is ignored.
- pParam2 (PMCI_GENERIC_PARMS) - input
- A pointer to the MCI_GENERIC_PARMS structure.
Returns
- rc (ULONG) - returns
-
- MCIERR_SUCCESS Device released successfully.
- MCIERR_INVALID_DEVICE_ID The device ID is not valid.
- MCIERR_INVALID_FLAG Flag (ulParam1) is invalid.
- MCIERR_FLAGS_NOT_COMPATIBLE Flags cannot be used together.
Remarks
Ownership of a physical device is managed dynamically. Using `MCI_RELEASEDEVICE` ensures that system resources are available for other background or foreground tasks that may require the hardware.
Example Code
The following code illustrates how to acquire and then release a device.
MCI_GENERIC_PARMS mciGenericParms;
USHORT usDeviceID;
HWND hwndMyWindow;
mciGenericParms.hwndCallback = hwndMyWindow;
/* Acquire the device for exclusive access */
mciSendCommand(usDeviceID,
MCI_ACQUIREDEVICE,
MCI_NOTIFY | MCI_EXCLUSIVE,
(PVOID) &mciGenericParms,
0);
/* Device will be exclusively acquired once MM_MCIPASSDEVICE is received */
/* ... Perform operations ... */
/* Release the device resources */
mciSendCommand(usDeviceID,
MCI_RELEASEDEVICE,
MCI_NOTIFY,
(PVOID) &mciGenericParms,
0);