C#에서 Delphi DLL을 호출하기
아래 주소에서 Convertion Data Type을 확인할 수 있다.
http://netcoole.com/delphi2cs/datatype.htm
우선 Delphi DLL 에서 호출할 함수의 형태를 파악한다.
ex )
TestDll.dll
function DllTest(Content : string, pData : pointer, Length : integer) : boolean ; stdcall;
var
...
begin
...
end;
의 형태라 가정하면
C#에서는 다음과 같이 정의를 해주어야 한다.
[DllImport("TestDll.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
public static extern bool DllTest(string Content, byte[] pData, int Length);
혹은 내부 구현에 따라서 다음과 같다.
[DllImport("TestDll.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
public static extern bool DllTest(string Content, object pData, int Length);
☆ CallingConvention 및 CharSet은 해당하는 값으로 변경하여 사용하도록 한다.
그 후 기존의 함수를 호출하듯 사용해주면 된다.