Write standard DLL with Delphi

xiaoxiao2021-03-17  213

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;

转载请注明原文地址:https://www.9cbs.com/read-129544.html

New Post(0)