I try to send a inno-setup string to a C# Dll like in this thread Returning a string from a C# DLL with Unmanaged Exports to Inno Setup script
My problem in this case is that i have the non unicode inno setup and so can't use the widestring. In some delphi forums i read that the string type i should use is widestring. In the above thread it also uses widestring. When i try it with a normal string i receive only one letter from my C# message. EDIT: the alert only shows one letter, the RTFText shows the message with spaces in between Is there a workaround that i could use so that i get the full message ?
Switching to the unicode inno setup would be nice but in the current stage of the development this sadly is not an option.
Since the comments say you need code here it is, it is nothing more than in the above thread mentioned, but maybe i am wrong here ;) .
function GetInformationEx(out message: String):Integer;
external 'GetInformationEx@{src}\data\tools\ZipLib.dll stdcall loadwithalteredsearchpath';
procedure ProgressCallback(progress:Integer);
var
AStr: String;
returnCode : Integer;
begin
WriteDebugString('ProgressCallback called');
if(progress > pbStateZip.position) then
begin
pbStateZip.position := progress;
lblState2.Caption := IntToStr(progress)+' %';
try
returnCode := GetInformationEx(AStr);
if returnCode = 0 then begin
alert(AStr);
revProgresses.UseRichEdit := True;
revProgresses.RTFText := AStr;
end
except
ShowExceptionMessage;
end;
end
if(progress >= 100)then
begin
KillTimer(0,m_timer_ID);
WriteManufacturerTextFile(ExpandConstant('{app}\projects'));
FileOperationsAfterExtraction();
end
WriteDebugString('ProgressCallback leave');
end;
And the C# bit:
[DllExport("GetInformationEx", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
public static int GetInformationEx([MarshalAs(UnmanagedType.BStr)] out string strout)
{
int returnCode = 0; //success
try
{
string something = "ladida\0";
strout = something;
}
catch
{
strout = "";
returnCode = 1; //Error
}
return returnCode;
}