BUG: AllocConsole() Does Not Set Error Code on Failure
PSS ID Number: Q105564
Article last modified on 03-18-1994

3.10

WINDOWS NT


----------------------------------------------------------------------
The information in this article applies to:

 - Microsoft Win32 Software Development Kit (SDK) for Windows NT
   version 3.1
----------------------------------------------------------------------

SYMPTOMS
========

The documentation for AllocConsole() states the following:

   If the function succeeds, the return value is TRUE; otherwise, it
   is FALSE. To get extended error information, use the GetLastError()
   function.

Upon failure, AllocConsole() does not set the error code.

STATUS
======

Microsoft has confirmed this to be a bug in Windows NT 3.1.

MORE INFORMATION
================

The following sample code demonstrates the problem:

#include <stdio.h>
#include <windows.h>

void main()
{¬
   BOOL bSuccess;

/* Comment out the following line and GetLastError() will   */
/* return 999; otherwise, GetLastError() returns 1812.      */

   FreeConsole();

   SetLastError( 999 );

   bSuccess = AllocConsole();
   if( !bSuccess )
      puts( "AllocConsole failed" );
   printf( "The last error is: %d\n", GetLastError() );
   getchar();
}

Additional reference words: 3.10
KBCategory:
KBSubcategory: BseCon

=============================================================================

Copyright Microsoft Corporation 1994.
