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.