Microsoft KB Archive/255670
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:
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