<p>Am 01.07.2014 20:59 schrieb "Jonas Maebe" <<a href="mailto:jonas.maebe@elis.ugent.be">jonas.maebe@elis.ugent.be</a>>:<br>
><br>
> On 01/07/14 19:42, Paul Breneman wrote:<br>
>><br>
>> I'm doing the same thing in FPC and D7:<br>
>> StringLen := 14;<br>
>> MyReturnStr := 'test1234567890';<br>
>> Status := ps5000aGetUnitInfo( ps5000a_handle, @MyReturnStr[ 0],<br>
>> StringLen, requiredSize, RInfo);<br>
><br>
><br>
> It wrong in both FPC and D7 (and it will also crash on all platforms in the next version of FPC; in the current version, it will only crash on OS X). You are assigning a string constant to a pchar, and then telling the DLL to overwrite it.<br>
><br>
> In current release versions of FPC (where it doesn't crash), that will result in the data of that string constant getting overwritten. This means that if you assign 'test1234567890' somewhere else to a string, that string will actually get the value with which this string was overwritten the last time.<br>
><br>
> Use getmem to allocate writeable memory.</p>
<p>In case MyReturnStr is a Ansi-, Wide- or UnicodeString shouldn't "SetLength(MyReturnStr, StringLen)" work as well?</p>
<p>Regards,<br>
Sven</p>