FFI Win32 api calls with LPTSTR args?

Ned Konz ned at squeakland.org
Wed Jan 26 02:39:08 UTC 2005


On Tuesday 25 January 2005 2:40 pm, Cees de Groot wrote:

> I want to use some Win32 API functions to make my app a bit more windoze
> friendly, most notably to place temporary files in the correct location
> (GetTempPath) and to find out where the user's home directory is (haven't
> found that one yet ;)).
>
> My knowledge of FFI is as big as that of Win32, i.e. almost completely
> absent. I haven't seen an example that uses the 'LPTSTR' (char **?)
> argument type, so I'm a bit at a loss as how to do this - could somebody
> help me here?

Actually, LPTSTR is just a pointer to a TSTR. But a TSTR is either a 16-bit or 
an 8-bit character, depending on a macro setting. And so you'd either call 
GetTempPathA or GetTempPathW, depending on character size (8 bit or 16 bit, 
respectively)

So, assuming that 8-bit chars are OK for you, it'd be

GetTempPathA(DWORD nBufferLength, LPCTSTR lpBuffer );

Andreas explains how to return strings:
http://lists.squeakfoundation.org/pipermail/squeak-dev/2002-April/038604.html

Some information about pointer-to-pointer usage:
http://lists.squeakfoundation.org/pipermail/squeak-dev/2003-September/067362.html

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list