Passing Buffers and Strings

A number of the NPP functions take as parameters the address and size of a buffer to be filled with a data structure of variable size. The buffer is allocated by the caller and passed to Win32, along with a DWORD parameter indicating the buffer's size in bytes. In many cases, an LPDWORD parameter is also passed in which the called function may indicate the number of bytes of data that it retrieved. The called function should compare the size of the buffer supplied by the caller with the number of bytes retrieved. If the supplied buffer is not large enough to contain at least one complete record, the NPP function should return failure, setting the last error code to ERROR_INSUFFICIENT_BUFFER.

NPP functions should store fixed-length structures contiguously starting at the beginning of the buffer, so that simple indexing can be used to access the Nth structure in an array of structures. If the returned data includes variable-length strings, the fixed-length data structures will contain pointers to these strings. The strings themselves will be placed at the end of the buffer. Note that pointers to strings or other variable length data are actual 32-bit pointers and are not offsets into the buffer.

Windows 95 uses DBCS ANSI/OEM character sets. When a buffer is used to pass and return strings, the specified buffer size represents the number of bytes that will fit, and not the number of characters. This differs from Windows NT, which uses Unicode and allows the number of characters to be specified.