In fact this code can be simplified considerable. This method encodes a string in the format required by Win32 for a resource string:

1) convert value to MCStringRef
2) encode stringref as UTF-16LE
3) ensure UTF-16 has a terminating NUL *included* in the length
4) call windowsversioninfoadd

So:

1) needs to be done by using a ctxt . ConvertToString() call (you'll need a tempoarary ExecContext).
2) needs to be done use MCStringConvertToBytes with UTF-16LE encoding
3) ConvertToBytes gives you a malloc'd array, so just check if the last two bytes are zero and if not add two zero bytes.