Hi, I have problems sending using a Dll procedure with parameters, im not allowed to add parameters to the call of the dll method in my test project.
Im trying to call this dll method:
procedure Transfer(sMessage: PChar); stdcall;
begin
MainForm.ShowThis(sMessage);
end;
exports
Transfer;
TestProj using this:
procedure TForm1.Button1Click(Sender: TObject);
var
DLLHandle : THandle;
begin
DLLHandle := LoadLibrary ('C:\Program Files\Borland\Delphi5\Projects\Dll\MyLink.dll');
if DLLHandle >= 32 then
try
@Trans := GetProcAddress (DLLHandle, 'Transfer');
if @Trans <> nil then
Trans //Would like to say something like: Trans('Hello')
else
Showmessage('Could not load method address');
finally
FreeLibrary(DLLHandle);
end
else
Showmessage('Could not load the dll');
end;
The compile error i get if i use the "Trans('Hello')" is : [Error] Unit1.pas(51): Too many actual parameters.
Im allowed to run it without the parameters but then i only get jiberish in my showmessage box and a crash after, since i dont send any message.
So the question is how do i get to send a string as a parameter into the dll ? what am i doing wrong ?