AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

How to - string in DLL

Ein Thema von WojTec · begonnen am 16. Jun 2011 · letzter Beitrag vom 22. Jun 2011
Antwort Antwort
Seite 3 von 3     123   
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
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.349 Beiträge
 
Delphi 11 Alexandria
 
#22

AW: How to - string in DLL

  Alt 22. Jun 2011, 16:36
I think this is a problem with the size parameter.

You always have to have in mind that one character is one byte in Delphi 7 and two bytes in Delphi 2010.

How does the code for reserving the memory, ... look like?
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
WojTec

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

Re: How to - string in DLL

  Alt 22. Jun 2011, 19:28
Hm, my functions working as in example on 1st page in this thread, size is length of S, in Ansii should be S length, but in Unicode length * 2 if we talking about bytes nor string length, but the same code working if both EXE and DLL are Ansii OR Unicode. So, what I should to do?
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 3 von 3     123   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz