473,513 Members | 11,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using delphi dll from c#

I have DLL written in Delphi 6. Its prototype is below:
function EnumUserGroups(Proc: TEnumUserGroupProc; APtr: Pointer):
LongInt; stdCall;

I have declared it in c# like below: (VS 2003)

[DllImport(POSDLL)]
public static extern int EnumUserGroups(UserGroupCallBack callBack,
object obj);

when I call it from c# like:
POSSRV.EnumUserGroups(new UserGroupCallBack(Form1.GetUserGroup), null);

in delphi side the parameter APtr is not nil.

What is the correct definition of the function in c# side?

thanks.

Huseyin Altun

Nov 16 '05 #1
2 6378
Hi ,

Just for the benefit of any expert C# folks that might not know Delphi,
Huseyin seems to want to invoke a managed delegate as a callback from an
unmanaged Delphi 6 dll. Offhand I would say that he can't do this but maybe
someone knows better than me. Delphi 6 is a pre .NET tool and has no
knowledge per se of managed code. Another option might be to simply stuff
the objects to be enumerated into some kind of structure (on the Delphi
side) and simply return the lot in one hit.

Cheers

Doug Forster

"Huseyin Altun" <al***********@hotmail.com> wrote in message
news:uO**************@TK2MSFTNGP12.phx.gbl...
I have DLL written in Delphi 6. Its prototype is below:
function EnumUserGroups(Proc: TEnumUserGroupProc; APtr: Pointer):
LongInt; stdCall;

I have declared it in c# like below: (VS 2003)

[DllImport(POSDLL)]
public static extern int EnumUserGroups(UserGroupCallBack callBack,
object obj);

when I call it from c# like:
POSSRV.EnumUserGroups(new UserGroupCallBack(Form1.GetUserGroup), null);
in delphi side the parameter APtr is not nil.

What is the correct definition of the function in c# side?

thanks.

Huseyin Altun

Nov 16 '05 #2
There no problem for callback function. It works well.
My problem is second parameter. for the second parameter I have passed null
parameter. I excepted that in the dll I get nil parameter.
But parameter is not nil. It has a pointer assigned..

"Doug Forster" <doug at _ZAPTHIS_
toniq_ZAPTHIS_DOT_ZAPTHIS_co_ZAPTHIS_DOTnz> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
Hi ,

Just for the benefit of any expert C# folks that might not know Delphi,
Huseyin seems to want to invoke a managed delegate as a callback from an
unmanaged Delphi 6 dll. Offhand I would say that he can't do this but maybe someone knows better than me. Delphi 6 is a pre .NET tool and has no
knowledge per se of managed code. Another option might be to simply stuff
the objects to be enumerated into some kind of structure (on the Delphi
side) and simply return the lot in one hit.

Cheers

Doug Forster

"Huseyin Altun" <al***********@hotmail.com> wrote in message
news:uO**************@TK2MSFTNGP12.phx.gbl...
I have DLL written in Delphi 6. Its prototype is below:
function EnumUserGroups(Proc: TEnumUserGroupProc; APtr: Pointer):
LongInt; stdCall;

I have declared it in c# like below: (VS 2003)

[DllImport(POSDLL)]
public static extern int EnumUserGroups(UserGroupCallBack callBack,
object obj);

when I call it from c# like:
POSSRV.EnumUserGroups(new UserGroupCallBack(Form1.GetUserGroup),

null);

in delphi side the parameter APtr is not nil.

What is the correct definition of the function in c# side?

thanks.

Huseyin Altun


Nov 16 '05 #3

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

Similar topics

16
3040
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...
7
6486
by: Sanjay Kedare | last post by:
Hi, I am evaluating various alternatives of converting Delphi (Ver 4.0) screens to C# screens. Are there any tools available for such conversion? if yes how much conversion do they achieve? The...
4
1593
by: David Lozzi | last post by:
How can it be done? I was thinking something like this: Select Case request.querystring("report") Case "Report1" dim rpt as new Report1 Case "Report2" dim rpt as new Report2 and so on.... ...
1
4456
by: denis | last post by:
hello I'm using a dll made in c++ in a delphi app, but get some errors I've use stdcall for the parameters match. I need someone have use C dll in delphi tell me if there is missing something....
1
3248
by: Bart Roozendaal | last post by:
Hi, I have setup a (my first) C# assembly. I am using the COM Interop services to use the assembly from a Delphi program. Is there a way to return a XmlDomDocument object from the assembly to...
3
2976
by: Anoop | last post by:
Hi All, I have a GUI module written in Delphi32. There is another main application written in CSharp.Net. I want to call the delphi GUI Form from with in CSharp.Net Code. The .Net application will...
0
1566
by: Alberto Salvati | last post by:
Hi, all. I'm a delphi developer who is working on a very old delphi application that uses db2v7 via ADO (Mdac). I know that v7 is very, very old, but at this moment, we cant' upgrade to a...
4
4079
by: =?Utf-8?B?ZGF2ZWJ5dGhlc2Vh?= | last post by:
Dear List, We have a large application written in Delphi. I am writing a mobile app written in .NET (C#) which reads and writes into the Delphi applications Oracle database via a .NET Web...
7
2057
by: Ryanivanka | last post by:
hi, I am using a delphi DLL in vc++,static linked with ".h"and "lib". the export functions in DLL are "__stdcall",but the function doesn't work well,it often returns some weird values. when I add...
0
7254
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
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7373
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
7432
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...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.