Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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
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
result := 0;
FreeLibrary(dllHandle) ;
begin
ShowMessage('dll not found ') ;
–
–
A C# DLL is a managed assembly and does not export its functionality via classic PE exports. Your options:
Use C++/CLI mixed mode to wrap the C#. You can then export functions in unmanaged mode in the usual way.
Use Robert Giesecke's UnmanagedExports. This is perhaps more convenient than a C++/CLI wrapper.
Expose the managed functionality as a COM object.
Once you get as far as choosing one of these options you will have to deal with your misuse of the string
data type. That's a private Delphi data type that is not valid for interop. For the simple example in the question PWideChar
would suffice.
–
–
–
–