Microsoft KB Archive/137194

{|
 * width="100%"|

PRB: GetOpenFileName nMaxFile Interpreted Incorrectly

 * }

Q137194

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), included with:
 * Microsoft Windows 95

-

SYMPTOMS
In a 16-bit Windows-based application, call GetOpenFileName with a string buffer of 10 characters and set nMaxFile to 10. Double-click a file whose full path name is 10 characters long. The file name is returned and the 11th character in the buffer is set to 0. This is a problem because the application has written beyond the specified length of the buffer.

CAUSE
Windows 3.1 had this same problem, so this behavior was maintained in Windows 95 for compatibility reasons.

RESOLUTION
Applications should make sure that they can handle having this API overwrite one more byte than the size that they passed in.

STATUS
This behavior is by design.

Keywords : kbCmnDlg kbCmnDlgFileO kbCmnDlgSave kbGrpDSUser kbOSWin95

Issue type : kbprb

Technology : kbAudDeveloper kbWin32sSearch kbWin32API