You can use PWideChar or PAnsiChar just as the Windows
API internally uses too.
If you want to return such a value:
Just give a PWideChar and its size as variable parameter. If the size is not sufficient, you return the size you need. If the size is sufficient you copy the data into the buffer.
This is the way the
API manages it. And it works well.