Strings I/O (Delphi DLL)

PDECODE

Active Member
Hi !

Do you have some experience with parsing strings to Delphi DLL ?

Working with LONG i have no problem:

IN DELPHI:

Function GetV(): Longword;
begin
Result := 111;
end;
-----------------------
IN PROGRESS:
Procedure GetV EXTERNAL "My.dll":
DEFINE RETURN PARAMETER retVER AS Long.
END PROCEDURE.

Run GetV (Output myRES).
Message myRES VIEW-AS ALERT-BOX ERROR BUTTONS OK.

this part is OK ..... but problem is with STRINGS:

IN DELPHI:

Function GetV2(): String;
begin
Result := 'Hi !';
end;
-----------------------
IN PROGRESS:

Procedure GetV2 EXTERNAL "my.dll" STDCALL :
DEFINE RETURN PARAMETER retVER AS Memptr.
END PROCEDURE.

Def Var MemptrVar AS MEMPTR.
Def Var myRES AS Char NO-UNDO.
Run GetV2 (Output MemptrVar).
myRES = GET-STRING(MemptrVar, 1).
Message myRES VIEW-AS ALERT-BOX ERROR BUTTONS OK.
SET-SIZE(MemptrVar) = 0.

this is not working ...

I try all combinations by defining dll:
- on delphi side "register pascal cdecl stdcall safecall" directives
- on progress side "CDECL | PASCAL | STDCALL" directives

Do you have any ideas, or working example ?

the same problem is with INPUT-OUTPUT string params ...

PS: on knowledge center i found:
However, for an OUTPUT parameter, you must use the GET-POINTER-VALUE and SET-POINTER-VALUE functions to access the data on return.
with this i have also no success :-(
 
Top