Thema: Delphi How to - string in DLL

Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#18

Re: How to - string in DLL

  Alt 20. Jun 2011, 11:48
Oh gosh, I forgot add stdcall before external in app. Ah Now working! Thanks

Also a few of you told that better is using WideChar. I tried this:

Delphi-Quellcode:
// In DLL

function FooncUni(Data: WideString): WideString; stdcall;
var
  S: string;
begin
  S := 'foo' + Data;

  Result := S;
end;

// In app:

function FooncUni(Data: WideString): WideString; stdcall external 'StringDLL.dll';

Caption := FooncUni('bar'); // Caption is 'foobar'
and working without any problems (as normal string type in EXE, that's cool ). But early @himitsu told:

How to use the functions, they are required to something in this case?

Also another think: to use Ansii or Unicode I have to write 2 functions with PWideChar and PAnsiChar parameters? Or one lets say Unocode version and second to convert Unicode Buffer to Ansi - how? And WideString - it is always Unicode?
  Mit Zitat antworten Zitat