Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi DLL in VB

Status
Not open for further replies.

KempCGDR

Programmer
Jan 10, 2003
445
GB
Hi, I have a DLL written in Delphi that I want to call from a VB program. It gives me errors no matter what I try, so I think I need to tell the function in the DLL to use a different calling convention, does anyone know which one I can use? Here is what Delphi says about the ones I have available for the function:
[tt]
Directive Parameter order Clean-up Parameters in registers?
register Left-to-right Routine Yes
pascal Left-to-right Routine No
cdecl Right-to-left Caller No
stdcall Right-to-left Routine No
safecall Right-to-left Routine No
[/tt]

Also, is there anything else I need to tell VB about the DLL?

I also can't select the DLL in the reference options even if I browse for it (it says it cannot reference the file).

The DLL works fine when called from a Delphi program.

Thanks
 
I've done it, had to use the stdcall convention.
 
I've done it too.
Couple of points, however: stdcall is right, but unless you have chosen to make an OLE DLL or similar, you don't add the DLL to your project using references.

I use mine by having declares very similar to the ones you use for Windows API work.

If that is enough to get you moving, great. If not, reply and I'll strip down my DLL project and send you some Delphi code off list. (It is a VB forum...:>)
 
Don't worry it's working perfectly now. I wasn't actually trying to add a reference, just wondered if that would accept it out of curiosity.

Just out of interest, I wrote the DLL to accept a PChar parameter and also return one, I am passing and getting a string back in my VB app ok but will there be any forseeable problems with this anywhere down the line? As far as I could tell a VB string is done in the same way as a Delphi PChar, but I could be wrong.
 
Havent run into any myself.
Just ensure that the string is large enough if you intend to alter one 'in situ' as it were.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top