I created a DLL in VS2013 using File/New Project/Class Library. I then tried to load it dynamically in Delphi. But Delphiis returning NIL
for procedure GetProcAddress
.
My C# & Delphi code looks like what I have posted below. In the code GetProcAddress
is returning NIL
. Please advise if I am missing something.
C# Code
using System;
namespace TestDLL
{
public class Class1
{
public static string EchoString(string eString)
{
return eString;
}
}
}
Delphi Code
Type
TEchoString = function (eString:string) : integer;stdcall;
function TForm1.EchoString(eString:string):integer;
begin
dllHandle := LoadLibrary('TestDLL.dll') ;
if dllHandle <> 0 then
begin
@EchoString := GetProcAddress(dllHandle, 'EchoString') ;
if Assigned (EchoString) then
EchoString(eString) //call the function
else
result := 0;
FreeLibrary(dllHandle) ;
end
else
begin
ShowMessage('dll not found ') ;
end;
end;