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

Q255670



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





SYMPTOMS

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:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
\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).



CAUSE

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.



RESOLUTION

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.



STATUS

This behavior is by design.



MORE INFORMATION

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.