Delphi-Quellcode:
foo := 'foo'+ s;
if Assigned(Buffer) then
StrLCopy(Buffer, PWideChar(foo), lenBuffer);
You try to copy lenBuffer Bytes from foo, but it does not have so many Bytes.
By the way: I prefer the way most of the
API functions work:
First I ask for the buffer size needed, then I reserve enough memory and ask for the data itself.