Thema: Delphi How to - string in DLL

Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#21

Re: How to - string in DLL

  Alt 22. Jun 2011, 15:32
There is another problem - compatibility Ansii/Unicode.
DLL is compiled with D2010, it uses unit with string type.
In API unit I strings declared as AnsiString:

Delphi-Quellcode:
S: AnsiString;
S := FuncReturnsString();
StrLCopy(lpBuffer, PAnsiChar(AnsiString(S)), nSize) // second typecast is from old version
If both DLL and app are compiled in Ansii compiler (D7) - it working, if in Unicode (D2010) - also working. Of one compiled in Ansii and second in Unicode, then raises invalid pionter operation exception, but buffers has correct data. I don't understand. What I'm doing wrong?
  Mit Zitat antworten Zitat