Loading and Unloading a Command Table

A driver loads a customized command table by calling mciLoadCommandResource, as follows:

uCommandTable = mciLoadCommandResource(hModuleInstance, "mcivcr", 0);

 

The call should be made when DriverProc receives a DRV_LOAD message. In the example, the command table’s name is “mcivcr”, which means “mcivcr” is the nameID argument to the table’s RCDATA statement. Additionally, if you place the command table in a separate file, the file must be named mcivcr.mci. The file must reside in a directory that is accessible by Win32’s CreateFile function.

A driver must unload its customized command table by calling mciFreeCommandResource. This call should be made when DriverProc receives a DRV_FREE message.

Every driver that defines a customized command table must use mciLoadCommandResource and mciFreeCommandResource to load and unload the table. There is one exception to this rule — if the command table defines a new device type and if the table resides in a separate file, then the driver does not need to explicitly load and unload the table. In this case, winmm.dll uses the device type name that the application specifies with the MCI_OPEN message to locate and load the command table.

In other words, a driver must explicitly load and unload its customized command table if the table is device-specific (as opposed to being for a device type) or if the table is linked to the driver.

If you create a customized command table for a one of the device types provided by Microsoft, and if you put the table in a separate file, do not use the device type name as the file name. Otherwise, other drivers will not be able to access the device type table provided by Microsoft because your table will override it.