Hent værdier fra String Table DLL
Er der nogen der har eksempler på hvordan String Table ressourcer i en dll hentes ind i Delphi. Prøver at gøre det med en TString:Jeg kalder en Delphi dll fra et basicmiljø. Delphi dll\'en kalder så en ressource delphi dll bestående af string table (der er navngivet med nummere), for at læse de strenge der står ind i min ressource dll, hvorefter de eksporteres til mit basicmiljø.
Dllfilen brager ned i linien: strIn.LoadFromStream(ResourceStream); med en Abstract error.
function GetLanguageStr(No: Integer): PChar; stdcall;
Var
DllInstance : integer;
str : string;
strIn : TStrings;
ResourceStream : TResourceStream;
begin
ShowMessage(\'DP 1...\');
DllInstance := LoadLibrary(PChar(\'langResDK.dll\'));
If DllInstance <> 0 then begin
try
ShowMessage(\'DP 2...\');
{ Get the string from langResDK.dll that correspond to No }
ResourceStream := TResourceStream.Create(DllInstance, \'#1\', RT_STRING);
ShowMessage(\'DP 3...\');
strIn := TStrings.Create;
ShowMessage(\'DP 4...\');
strIn.LoadFromStream(ResourceStream);
ShowMessage(\'DP 5...\');
ShowMessage(\'DP Hvad er der i streamen: \' + strIn.Strings[0]);
{Convert the pascal stype string back to a null terminated string}
{Return the string to the calling function}
GetLanguageStr := PChar(str);
except
on E:Exception do
begin
ShowMessage(\'DP Fejl: \'+E.Message);
raise;
end; { do }
end; { try - except }
end else { that is DllInstance <> 0 }
begin
MessageDlg(\'Error handling DLL.\',mtError, [mbOk],0);
end;
FreeLibrary(DllInstance);
end; { function }
