Unloading Stream Interface Drivers

A stream interface driver DLL can be unloaded in two ways, depending on the method by which the DLL was loaded. If the Device Manager loaded the DLL, the Device Manager detects the disconnection of the stream interface driver’s peripheral from the platform, such as when a PC Card is ejected from its socket. At this point, the Device Manager removes the driver’s entry from the HKEY_LOCAL_MACHINE\Drivers\Active key, calls the DeregisterDevice function to remove the peripheral’s device file name from the file system, and notifies the FreeLibrary function to unload the DLL. However, if an application loaded the DLL, the application must unload the DLL before it exits by calling DeregisterDevice.