Liberty BASIC provides two ways to pass strings as parameters into API/DLL calls. By default when passing a string as a parameter, Liberty BASIC copies the string and adds an ASCII zero to the end of the copy. This ASCII zero is called a "null terminator." Most Windows API calls expect this kind of zero-terminated string. This technique provides a copy of the original string to be passed to the API function. If the function then modifies that string directly (as in the kernel API function GetProfileString and a few others), then the Liberty BASIC application calling the function cannot access the modified string because only the copy is modified.

The way to fix this is for the code to include the ASCII zero onto the end of the string that will be used as a parameter in the API call. Liberty BASIC checks for the ASCII zero, and if it finds it, passes the memory address of original string and does not make a copy. This is only necessary if an application passes a string, expecting to get it back modified by the API or DLL function called.

Here is a code segment to get printer info using the GetProfileString API call:

'getpstr.bas - Get information using the GetProfileString API call

open "kernel32.dll" for dll as #kernel

'Notice that no ASCII zero characters are added to these strings

'because the program will not need to read any results out of the call