473,388 Members | 1,340 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Calling Delphi DLL from inside C# Window program

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=CallingConve ntion.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.
Nov 16 '05 #1
1 7202
Hi,

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

Cheers

Doug Forster

"ARTMIC" <AR****@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
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=CallingConve ntion.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.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ARTMIC | last post by:
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. i use the following declaration: static extern double...
16
by: glenn | last post by:
I've gotten a COM server written in C# and I can call it from a VBScript just fine and it works perfectly. However, I import it into Delphi 6 or Delphi 2005 and I can not get access to any of the...
3
by: JB | last post by:
I have an aplication which used to be created in Delphi 5. For various reasons we want to try to recode that in vb .net but the original application called functions inside one or more dlls that...
3
by: Andrew Poulos | last post by:
I've been asked to add some additional code to HTML that get generated by a 3rd party program. Currently the code that gets generated already includes a window.onload = init; The program lets...
2
by: Prabhat | last post by:
Hello ALL, I have ASP pages that calls some ISAPI dll that created using Delphi for generating reports. The report page opens fine for 1st time when invoked but next time i get error like "Name...
22
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
5
by: kelvin.koogan | last post by:
How can I call a function in a Delphi DLL from C++/CLI? The Delphi function is declared as follows: function Func1(IsDsb: Boolean; FirstStr, SecondStr : String): String; I've tried ...
7
by: Andrew Poulos | last post by:
Say I have this foo = function() { // blah }; bar = fuction(fnName) { /* If fnName equalled "foo" * How do I test that foo, as a function, * exists and then, if it exists, call it?
1
by: Julian Mensch | last post by:
My employer has developed an application in Delphi with a very complex user-interface that we may be transitioning to C# at some point. Our interface uses large numbers of tabbed sub-forms, with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.