This function registers a new device driver with the file system so that applications can access the driver’s special device file names.
HANDLE RegisterDevice( LPCWSTR lpszType DWORD dwIndex LPCWSTR lpszLib, DWORD dwInfo )
A handle to a device indicates success. Zero indicates failure. This is passed to the following functions exported by the client driver: XXX_Deinit, XXX_Open, XXX_PowerUp, and XXX_PowerDown.
Stream interface drivers are initialized by a call to this function. For most stream interface drivers, the Device Manager calls this function on behalf of the driver. However, applications can load their own special-purpose stream interface drivers, in which case they also call this function to register the driver. The IpszLib parameter is used to open the device. The IpszType parameter is a three-character string that identifies the function entry points in the DLL so that multiple devices can exist in one DLL. The lpszLib parameter is the name of the DLL that contains the entry points. Finally, dwInfo is passed to the initialization routine. So, for example, if there are two serial ports on a device and Comm.dll is the DLL implementing the serial driver, it presents the following initialization calls:
h1 = RegisterDevice( L"COM", 1, L"comm.dll",0x3f8 );
The DeregisterDevice function is used if a device is removed from the system or is being shut down:
In the following code example, h1 is returned from a call to this function.
DeregisterDevice( h1 );