Important Remarks on the Function Parameters of DLLs

Returning strings from the DLL to the application is always performed by returning a pointer to a memory area and, as a further parameter, an integer value for the length. The buffer size (in characters) must be passed so that buffer overflows are impossible. The string is always \0-terminated. If, for example, the buffer is too short, the returned string will be shortened and may result in incomplete return values. This is indicated by the API function's return value. LL_ERR_­BUFFER­TOO­SMALL will be returned in these cases.

The parameters are checked for correctness as far as possible. While developing a program it is therefore worth switching on the debug mode (see LlSetDebug()) and checking the return values. You can switch off the parameter check later using LL_OPTION_NOPARAMETERCHECK.

Please note that with Delphi the routines require "\0"-terminated strings just like the Windows API functions. It may be necessary to use the Pascal-string to C-string conversion routines.

Please note with C or C++ the C convention in source texts of having to enter, for example, the '\' in path entries twice: "c:\\temp.lbl" instead of "c:\temp.lbl".

Example:

INT    nSize = 16000;

LPWSTR pszBuffer = new TCHAR[nSize];

INT    nResult = <API>(hJob,...,pszBuffer,nSize);

 

if (nResult == LL_ERR_BUFFERTOOSMALL)

    {

    nSize = <API>(hJob,...,NULL,0);

 

    ASSERT(nSize > 0);

    delete[] pszBuffer;

    pszBuffer = new TCHAR[nSize];

    nResult = <API>(hJob,...,pszBuffer,nSize);

    }

 

...

 

delete[] pszBuffer;