Innosetup and DLL function with string parameter

434 views
Skip to first unread message

robn...@gmail.com

unread,
Mar 9, 2020, 10:39:47 AM3/9/20
to innosetup
I'm getting crazy to use, in a inno setup script, a function defined into a dll. The dll is made with Delphi XE10

The function has one parameter (type string) and returns a string. You can see the source below.


In the Innosetup 5 script i use the following code to declare the function.

function encryptstr(str:string):pchar;
external 'encryptstr@files:setup.dll stdcall delayload';

function decryptstr(str:string):pchar;
external 'decryptstr@files:setup.dll stdcall delayload';

The DLL is loaded in InitializeWizard



The problem is that the encrypstr function returns only the first character of the string. What's my mistake ?



unit misc;

interface

uses sysutils, encryp;

var
  returnstrvalue:string;


function encryptstr(str:pansichar):pchar;stdcall;
function decryptstr(str:pansichar):pchar;stdcall;

implementation

function encryptstr(str:pansichar):pchar;stdcall;
begin
  returnstrvalue:=EncryptString(str,'');
  result:=pchar(returnstrvalue);
end;

exports encryptstr;

function decryptstr(str:pansichar):pchar;stdcall;
begin
  returnstrvalue:=DecryptString(str,'');
  result:=pchar(returnstrvalue);
end;

exports decryptstr;


end.

Martijn Laan

unread,
Mar 9, 2020, 4:55:10 PM3/9/20
to inno...@googlegroups.com
Hi,

Most likely you're using an old Non Unicode version of Inno Setup while your DLL is using Unicode strings. 

Greetings,
Martijn

Op 9 mrt. 2020 om 15:39 heeft robn...@gmail.com het volgende geschreven:


--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/innosetup/c3d4db74-1151-4a4e-ad1f-d23dca9be5b5%40googlegroups.com.

robn...@gmail.com

unread,
Mar 10, 2020, 5:21:25 AM3/10/20
to innosetup
Yes i'm using the not unicode version (5.6.1) so right now i need to have the code for that version.

Anyway i'd like to know also the syntax for the unicode version (both DLL and Script)

thanks a lot
To unsubscribe from this group and stop receiving emails from it, send an email to inno...@googlegroups.com.

Virgo Pärna

unread,
Mar 10, 2020, 5:57:58 AM3/10/20
to inno...@googlegroups.com
On 10.03.2020 11:21, robn...@gmail.com wrote:
> Yes i'm using the not unicode version (5.6.1) so right now i need to
> have the code for that version.
>
> Anyway i'd like to know also the syntax for the unicode version (both
> DLL and Script)
>

If Ansi version supports Widestring, then this is probably easiest to
be used on both sides.
Otherwise, PAnsiChar or PWideChar properly on both sides.


--
Virgo Pärna
Gaiasoft OÜ
vi...@gaiasoft.ee
Reply all
Reply to author
Forward
0 new messages