using delphi dll from c#

H

Huseyin Altun

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
 
D

Doug Forster

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
 
H

Huseyin Altun

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
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 said:
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
 

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