This function registers a new device.
At a Glance
Header file: | Winbase.h |
Versions: | 1.0 and later |
Syntax
HANDLE RegisterDevice( LPCWSTR lpszType DWORD dwIndex LPCWSTR lpszLib DWORD dwInfo);
Parameters
lpszType
Long pointer to the null-terminated string that contains the device identifier prefix (for example COM, DEV, PGR); must be 3 characters long.
dwIndex
Specifies the device identifier index; must be a number from 0 through 9. For example, the index value for COM2 would be 2.
lpszLib
Long pointer to the null-terminated string that contain that device driver DLL module name.
dwInfo
Specifies instance information.
Return Value
A handle to a device indicates success. Zero indicates failure. This is passed to the following functions that are exported by the client driver: PRE_Open, PRE_Deinit, PRE_PowerUp, and PRE_PowerDown.
For stream-based devices, the drivers are DLL files. Each driver is initialized by a call to the RegisterDevice function (performed by the server process). The IpszLib parameter is used to open the device. The IpszType parameter is a three character string which is used to identify 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 in to the initialization routine. So, for example, if there were two serial ports on a device, and Comm.dll was the DLL implementing the serial driver, it would likely present the following initialization calls:
h1 = RegisterDevice(L"COM", 1, L"comm.dll",0x3f8);
hs
Remarks
The DeregisterDevice function can be used if a device is removed from the system or is being shut down. An example would be:
DeregisterDevice(h1);
where h1 was returned from a call to RegisterDevice.
See Also