🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #6

Re: Delphi calls to a C++ DLL

#6
From: helicon
Date: Fri, 02 Feb 1996 02:46
69 lines
2269 bytes
In article <310FD68B.208B@allaire.com>, jlund@allaire.com says...
;
;I have written a DLL in C++ that I am attempting to call from a Delphi EXE. I ca
;n call 
;DLL functions from my C++ apps, but not from my Delphi program. The Delphi app c
;alls the 
;DLL function, but most of the parameters passed are garbage. I tried the same te
;chniques 
;and syntax I found in the Delphi libraries, but to no avail. 
;
;For whatever reason it looks like the parameters are pushed and popped from the 
;stack 
;differently beween environments.  I've tried declaring the function in Delphi wi
;th 
;"stdcall" and "cdecl", and I've tried other data types in place of pchar. Any 
;suggestions?
;
;
;***************
;Delphi SNIPPETS
;***************
;
;{type, private}
;function GetFieldsForTable(
;   pcharDataSourceName, 
;   pcharUsername, 
;   pcharPassword, 
;   pcharTableName: pChar
;   ): integer;
;
;{implementation}
;function TODBCInformant.GetFieldsForTable; 
;   external 'patrik.dll' name 'GetFieldsForTable';
;
;{I call the function like this:}
;nIndex:= GetFieldsForTable(strpcopy(pcharBuiffer,'Test'),
;   strpcopy(pcharBuiffer,''),
;   strpcopy(pcharBuiffer,''),
;   strpcopy(pcharBuiffer,'Employees'));
;
;
;************
;C++ SNIPPETS
;************
;
;// My C++ header (.H) declares the prototype like this:
;extern "C" INT FAR PASCAL EXPORT GetFieldsForTable( 
;   LPSTR lpszDataSourceName, 
;   LPSTR lpszUsername, 
;   LPSTR lpszPassword, 
;   LPSTR lpszTableName 
;   );
;
;/* 
;My implementation uses the same format, and the function is named in the 
;exports section of the .DEF file.
;*/
;

Hi!

I think the problem is, that you use the same Buffer for each parameter. So you will get the same value 
(because it's the same pointer) in each parameter.

Hope it helps :-)

Bye

Andreas
Technical Details
Message-ID: <4erttn$l9v@newsfeed.via.at>
Path: arc1-ca.pugleaf.net!news.via.at!usenet
References: <310FD68B.208B@allaire.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.via.at!usenet
From: helicon@helicon.co.at (helicon)
Newsgroups: comp.lang.pascal.delphi.misc,comp.lang.c++
Subject: Re: Delphi calls to a C++ DLL
Date: 2 Feb 1996 02:46:15 GMT
Organization: helicon software development
Message-ID: <4erttn$l9v@newsfeed.via.at>
References: <310FD68B.208B@allaire.com>
NNTP-Posting-Host: helicon.via.at
Mime-Version: 1.0
X-Newsreader: WinVN 0.99.2