It's pretty much the same idea - you call GetTempPath while providing it with a char array to put the results into, and the length of the buffer.
@Spooky,
Rather than use memblocks, why not simply create a string that's long enough for the result and then pass that? Saves having to do the conversion from memblock chars to a string.
t$=gettemppath()
print t$
wait key
end
function gettemppath()
local TempPath as string
dll=freeDll()
load dll "kernel32.dll",dll
` Gets the size that the buffer needs to be
PathLength = call dll(dll, "GetTempPathA", 0, 0)
` Allocate the buffer (PathLength chars + 1 for the nul byte)
TempPath = space$( PathLength )
` Get the path into the buffer, +1 to hold the terminating nul
PathLength = call dll(dll, "GetTempPathA", PathLength+1, TempPath)
delete dll dll
endfunction TempPath
function freeDll()
repeat
inc i
until dll exist(i)=0
endfunction i