When an instance is disabled for a particular direction, the reference count for that direction is decremented. If this count reaches 0, the instance becomes truly disabled for that direction.
If the request is for both send and receive, and the instance only supports one direction, then either MIDIERR_SENDONLY or MIDIERR_RECEIVEONLY is returned (as appropriate), and the instance is not disabled for either direction. If the instance supports neither send nor receive, MIDIERR_NOT_ALLOWED will be returned. Therefore, the application should call MIDIQueryInstanceList to determine the capabilities of the instance before attempting to disable it.
MIDIDisableInstance has special meaning for hardware nodes. When a hardware node becomes truly disabled, the Type A driver that it represents is issued an close request. If this request fails then MIDIERR_HARDWARE_FAILED is returned, and the instance remains enabled with a reference count of 1.
If an application attempts to disable an instance for both directions simultaneously, it is possible for one direction to succeed and for the other to fail. In this case, the instance will be disabled for only one direction and the application will not know which direction that is. This can happen when disabling a hardware node or when the instance was enabled for only one direction. In the former case, MIDIERR_HARDWARE_FAILED is returned and in the latter case, MIDIERR_NOT_ALLOWED is returned.
Therefore, it is suggested that an application make separate MIDIDisableInstance calls to disable the instance for both directions. If the first call fails, the application can then take appropriate measures.