Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/255670

From BetaArchive Wiki

PRB: CreateEnvironmentBlock() Fails If the Environment Block Contains an Empty String


The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), included with:
    • Microsoft Windows NT Server version 4.0
    • Microsoft Windows NT Workstation version 4.0


The CreateEnvironmentBlock function fills a block of memory with a list of NULL-terminated strings that represent the environment variables for a specified user. This block is built by using values that are stored in the following registry key:

\Session Manager\Environment

If one of the values within this key contains an empty string, CreateEnvironmentBlock will fail. A subsequent call to the GetLastError function incorrectly returns zero (ERROR_SUCCESS).


An empty string is not a valid value for an environment variable. The system was not designed to expect or to handle an empty string value in this key.


If CreateEnvironmentBlock returns FALSE and GetLastError returns ERROR_SUCCESS, check the registry key shown in the "Symptoms" section for empty strings. Delete any value that contains an empty string.


This behavior is by design.


On a Microsoft Windows 2000-based computer, an empty string value in the environment key does not cause a problem when CreateEnvironmentBlock is called. The system ignores all such values when the environment block is built. Novertheless, an empty string is still not a valid value for an environment variable. Therefore, other unpredictable problems could occur as a result of an empty string value in this key.

Additional query words:

Keywords : kbAPI kbKernBase kbOSWinNT400 kbRegistry kbSDKWin32 kbDSupport kbGrpDSKernBase
Issue type : kbprb
Technology : kbAudDeveloper kbWin32sSearch kbWin32API

Last Reviewed: October 27, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.