PRB: CreateService or ChangeServiceConfig Fails with Error 31

Last reviewed: January 11, 1997
Article ID: Q154667
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT version 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.


KBCategory: kbprg kbprb
KBSubcategory: BseService
Additional reference words: 3.51 kbdss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.