Functions in the Win32 API that handle strings come in two flavors, one for ANSI strings and one for Unicode strings. Windows ME only supports the ANSI functions but Windows XP/Vista/7 support both. The functions are named with a single letter suffix, an
A
for the ANSI functions and a
W
for the Unicode functions. So for example both
CreateFileA
and
CreateFileW
exist. In C, this is finessed by the use of #define in the header files.
There are two ways to handle this:
A
functions. This will allow your code to work on all supported versions of Windows, but will prevent the use of Unicode on Windows XP/Vista/7 (this is typically only a problem if you are handling mixed language data), or
:dbcs
in define-foreign-function. This will cause it to switch between ANSI and Unicode versions depending on the operating system.
In either case, as well as calling the correct function, you must encode/decode any string arguments/results correctly, to match the
A
or
W
in the function name. The foreign types
win32:tstr
,
win32:lpctstr
and
win32:lptstr
correspond to the typical ones found in the Win32 API. For more information about these foreign types, see their manual pages in the
LispWorks User Guide and Reference Manual
.