The following code illustrates how to close a device context.
ULONG mciDriverEntry (PINSTANCE pInst, USHORT usMessage, ULONG ulParam1, ULONG ulParam2, USHORT usUserParam) { switch (usMessage) { case MCI_DEVICESETTINGS: return(InsertPage ((PMCI_DEVICE_SETTINGS_PARMS) ulParam2)); } }