DrvCreateServicesNode

BOOL
   DrvCreateServicesNode(
       PTCHAR
DriverName,
       SOUND_KERNEL_MODE_DRIVER_TYPE
DriverType,
       PREG_ACCESS
RegAccess,
       BOOL
Create
       );

The DrvCreateServicesNode function creates a connection to the service control manager and, optionally, creates a service object for the kernel-mode driver. The caller must have Administrator’s privilege.

Parameters

DriverName

Pointer to the driver name. Must match DriverName in registry path.

DriverType

Driver type, used for indicating the kernel-mode driver’s load group. The type is SOUND_KERNEL_MODE_DRIVER_TYPE. The value can be one of the following.

Value Definition
SoundDriverTypeNormal Adds kernel-mode driver to “base” load group.
SoundDriverTypeSynth Adds kernel-mode driver to “Synthesizer Drivers” load group.

The “Synthesizer Drivers” group is unknown to Windows NT and therefore is guaranteed to be loaded last.

RegAccess

Pointer to a globally-defined structure of type REG_ACCESS.

Create

If TRUE, the function creates a service object for the kernel-mode driver, if it does not already exist. If FALSE, the function does not create the service object.

Return Value

Returns TRUE if the operation succeeds. Otherwise returns FALSE.

Comments

The structure pointed to by RegAccess must be a single, globally-defined REG_ACCESS structure that the driver uses with all calls to drvlib.lib functions requiring a RegAccess parameter.

Under Windows NT, kernel-mode drivers are considered to be services under the control of the service control manager. The DrvCreateServicesNode function calls OpenSCManager to create a connection to the local service control manager. OpenSCManager is called with a desired access type of SC_MANAGER_ALL_ACCESS, which requires Administrators privilege. (For information about OpenSCManager, see the Win32 SDK.) The service manager handle returned by OpenSCManager is stored in the REG_ACCESS structure.

If the Create parameter is TRUE, the DrvCreateServicesNode function calls CreateService to create the kernel-mode driver service and obtain a service handle. The DrvCreateServicesNode function sets the service’s start type to SERVICE_DEMAND_START, so it will not automatically reload when the system is restarted. (For information about CreateService, see the Win32 SDK.)

A result of calling CreateService is the creation of a driver subkey under the \Services registry key. The path to the subkey is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DriverName.

If the Create parameter is FALSE, the function just creates a connection to the service control manager and saves the service manager handle returned by OpenSCManager in the REG_ACCESS structure. Anytime after calling DrvCreateServicesNode, you can call the DrvAccess macro to determine if access to the service control manager was granted.

For additional information, see Installing and Configuring your Driver, Using drvlib.lib.