PRB: CreateService or ChangeServiceConfig Fails with Error 31

ID: Q154667


The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API), included with:
    • Microsoft Windows NT 3.51


SYMPTOMS

The CreateService or ChangeServiceConfig API fails with the error code 31, ERROR_GEN_FAILURE, on Windows NT 3.51.


CAUSE

When obtaining a handle to the Service Control Manager via the OpenScManager API, a machine name is specified in the first parameter. If the machine name specified refers to the local machine, the ChangeServiceConfig and CreateService APIs will fail with an error code of

31, ERROR_GEN_FAILURE
if the name was specified without appending two backslashes (\) in front of the machine name. For example:
franki


RESOLUTION

Append two backslashes in front of the computer name for the first parameter to OpenScManager(). For example:

\\franki
The CreateService and ChangeServiceConfig API will now successfully execute.


STATUS

This behavior is by design.


MORE INFORMATION

The error code 31, ERROR_GEN_FAILURE, will only occur with the CreateService and ChangeServiceConfig API when the following conditions are met:

  • The lpServiceStartName parameter is not NULL.


  • The lpPassword parameter is not NULL.


Additional query words: kbdss


Keywords          : kbKernBase kbService kbGrpKernBase 
Version           : winnt:3.51
Platform          : winnt 
Issue type        : 


Last Reviewed: October 18, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.