RegisterDevice

The RegisterDevice function registers a new device.

Syntax

HANDLE RegisterDevice(LPCWSTR lpszType DWORD dwIndex LPCWSTR lpszLib DWORD dwInfo);

At a Glance

Header file: Winbase.h
Platforms: H/PC
Versions: 1.0 and later

Parameters

lpszType
Device identifier prefix (for example COM, DEV, PGR); must be 3 characters long.
dwIndex
Device identifier index; must be a number from 0 through 9. For example, the index value for COM2 would be 2.
lpszLib
Device driver DLL module name.
dwInfo
Instance information.

Return Value

Returns a handle to a device or zero for 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 will be DLL files. Each driver is initialized by a call to the RegisterDevice function (performed by the server process). The IpszLib parameter is what will be 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

DeregisterDevice