RegisterDevice (Windows CE 5.0)

Send Feedback

This function registers a new device. ActivateDeviceEx supersedes this function.

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

Parameters

  • lpszType
    [in] Long pointer to the null-terminated string that contains the device identifier prefix, for example COM, DEV, or PGR. Must be three characters long.
  • dwIndex
    [in] Device identifier index. Must be a number from 0 (zero) through 9. For example, the index value for COM2 is 2.
  • lpszLib
    [in] Long pointer to the null-terminated string that identifies the device driver DLL name.
  • dwInfo
    [in] Instance information.

Return Values

ActivateDeviceEx supersedes this function.

A handle to a device indicates success. Zero indicates failure. This handle is obtained from the driver's XXX_Init (Device Manager) function and is passed to the XXX_Open (Device Manager), XXX_Deinit (Device Manager), XXX_PowerUp (Device Manager), and XXX_PowerDown (Device Manager) functions.

For devices that expose the stream interface, the drivers are DLL files. The RegisterDevice function initializes each driver. The Device Manager calls this function on behalf of the driver. However, applications can load custom stream interfaces, in which case they also call this function to register the driver. The lpszLib parameter opens the device. The lpszType parameter is a three-character string that identifies the function's 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. Pass the dwInfo parameter to the initialization routine.

Remarks

Use the DeregisterDevice function, if the user removes a device from the system or if the system is shutting down, and if the handle was returned from a call to RegisterDevice.

This function is only callable by trusted callers. The following list shows the ramifications of this:

  • The installer for the driver must use a relative path for the DLL. The relative path must point to the Windows directory or other places in the specified search path.
  • If the installer uses an explicit path, it is responsible for setting the correct path and not pointing to a directory that untrusted code can modify.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.

See Also

Stream Interface Drivers | ActivateDeviceEx | DeregisterDevice | XXX_Deinit (Device Manager) | XXX_Init (Device Manager) | XXX_Open (Device Manager) | XXX_PowerDown (Device Manager) | XXX_PowerUp (Device Manager)

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.