Calling Delphi DLL from inside C# Window program

G

Guest

Hello,

could someone please help me out, i'm trying to call a Delphi 6.0 custom DLL
from inside of a C# windows project. what am i doing wrong? i use the
following declaration:
public class WindowDesignerForm : System.Windows.Forms.Form
{
[DllImport("calwin.dll", EntryPoint="CalcWindow",
ExactSpelling=false,CallingConvention=CallingConvention.StdCall)]
static extern double CalcWindow(long OrderNum, long WinNum);
etc...
}

I call the above dll like this inside a button click event:
double d = 0;
d = CalcWindow(or,wn);

The problem is that when i call this DLL nothing happens, it should display
a messageBox telling me what parameters i passed to the DLL. nothing appears,
and the return value is always 0. (I do not get any gpf's/access violations
when i call this code)


The delphi 6.0 code is as follows:
function CalcWindow(OrderNum:longint; WinNum: longint): double; stdcall;
Implementation
function CalcWindow(OrderNum:longint; WinNum: longint): double;

in the project source file, i export the dll like this:

exports
CalcWindow name 'CalcWindow';


I can call the dll from inside another Delphi exe, but inside the C# exe i
can't seem to get the same results, can somone spot what i'm doing wrong
with this?

Thanks.
 
D

Doug Forster

Hi,

It works perfectly for me. What happens when you set a breakpoint in the
Delphi debugger?

Cheers

Doug Forster
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top