Board index » delphi » Delphi 2 DLL works when called from Delphi, but not from VC++

Delphi 2 DLL works when called from Delphi, but not from VC++

I have written a DLL in Delphi 2.0. Thi DLL has 1 function that is
exported from it. When called from a Delphi program it works
fine, however when called from a Visual C++ program it doesn't work the
same.

        To start off, I will mention that the DLL loads fine. The problem
is... there are 5 PChar variables that are passed to the function.
As soon as they are passed into the function I convert them
to strings using the "StrPas" function. Then, as a debug feature,
I am writing these strings to a dialog box, to see if the parameters
were passed into the function successfully.
        When I call the function from a Delphi-written program they are
fine. When I call them from a Visual C++ written program, garbage
appears in the strings that I write to the dialog box. I also tried using
type-casting [string(PCharVariable)] to convert the PChars to
strings, but ended up with the same results.

        Any body have any suggestions??? If you can, instead of
only responding to this newsgroup or this e-mail, I would appreciate
it if you could forward your response to "anthony.del...@prograph-inc.com"
as well. (I read that mail much more often.)

Thanks in advance!,
--Anthony DeLuca, Prograph Bindery Systems

 

Re:Delphi 2 DLL works when called from Delphi, but not from VC++


Are you exporting the functions as 'stdcall'?  Delphi 2, by default, uses a
different convention which is faster, but incompatible with anything
else...

--
David S. Becker
ADP Dealer Services (Plaza R&D)
d...@plaza.ds.adp.com
(503)402-3236

Anthony P DeLuca <adel...@fyi.net> wrote in article
<32F8B216.2...@fyi.net>...

Quote
> I have written a DLL in Delphi 2.0. Thi DLL has 1 function that is
> exported from it. When called from a Delphi program it works
> fine, however when called from a Visual C++ program it doesn't work the
> same.

[snip]

Other Threads