1. You cannot assign a string space in the DLL to the call function, and the string space must be allocated outside. 2. You cannot use the string as the return value, you see the Win API has a string return value. 3. Generally, it is generally transmitted to the space length of the function PCHAR, avoids insufficient string space.
Common writing
Fun XXX (PS: PCHAR; Ilen: Integer): integervar s: string; begin s: = 'abc'; result: = Length (s); if Ilen = 0 THEN EXIT; if Result> lyn the result: = ilen; CopyMemory (PS, PCHAR (S), Result);
VAR SS: STRING; I: Integer; Begin I: = XXX (PCHAR (SS), 0); SETLENGTH (SS, I); I: = XXX (PCHAR (SS), I); END;