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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DLL from Delphi 1

Status
Not open for further replies.

BlackDice

Programmer
Mar 1, 2004
257
US
I have created a DLL in C++ that I have been testing from VB to see if it works. In making the DLL I had to use BSTR data types and the _stdcall calling convention so that the function I'm calling is compatible with VB. What's the difference in using it from Delphi?

bdiamond
 
See "External declarations" in Delphi help.

Delphi can handle StdCall.

For passing strings from DLLs written in C it is usual to use pchar, but that does not mean it is the only option.

Good luck
Simon
 
Thanks VintageWine! I have given you a star. But the BSTR's are the parameters for the function. The only return value is an integer. So the function is like this:

int Export(BSTR szServer, BSTR szDB, BSTR szUser, BSTR szPassword, BSTR szSQL, int nExportType)

Thanks very much for your help and any future help!

bdiamond
 
2 stars in one day, must be a good one [sunshine]

I take it the BSTRs are strings.

You could have a function like:

int Export(pchar szServer, pchar szDB, pchar szUser, pchar szPassword, pchar szSQL, int nExportType)

The trouble with pchars is handling the memory that they point to.

You could try using OleVariants. Keep your C DLL with BSTRs, but declare the function within Delphi using olevariants. No Guarentees I'm afraid :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top