Microsoft KB Archive/207008

{|
 * width="100%"|

BUG: lstrcat, lstrcpy, and lstrcpyn Do Not Set Win32 Error Code on Failure

 * }

Q207008

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), used with:
 * Microsoft Windows NT Server version 4.0
 * Microsoft Windows NT Workstation version 4.0
 * the operating system: Microsoft Windows 2000

-

SYMPTOMS
The GetLastError function returns 0 (zero) when lstrcat, lstrcpy, and lstrcpyn fail.

RESOLUTION
To work around this issue, applications that must run on Windows NT or Windows 2000 should perform error handling based on the return value of the lstrcat, lstrcpy, and lstrcpyn functions, but not on the result of GetLastError.

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

MORE INFORMATION
The lstrcat, lstrcpy, and lstrcpyn functions should return NULL when they fail. In addition, these functions should set a Win32 error code to be returned by a call to the GetLastError function. Windows 95 and Windows 98 set the error code appropriately. However, Windows NT and Windows 2000 do not set the error code, and therefore GetLastError always returns 0 (ERROR_SUCCESS).

Additional query words:

Keywords : kbAPI kbKernBase kbOSWinNT400bug kbOSWin2000bug kbString kbDSupport kbGrpDSKernBase

Issue type : kbbug

Technology : kbAudDeveloper kbWin32sSearch kbWin32API