BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help writing interface to VB Dll - Not Correctly Sending Dat

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal
View previous topic :: View next topic  
Author Message
Shawn Call
Guest





PostPosted: Sun Dec 14, 2003 4:42 am    Post subject: Help writing interface to VB Dll - Not Correctly Sending Dat Reply with quote



I'm trying to interface a VB DLL to Delphi. I wrote the interface, but
found it was not sending the long data type correctly to the VB
Component. I worked with the DLL developer, who recompiled the code to
send me back what it received, that's when I discovered the data was
not coming across correctly.

Here's my interface code:
implementation
function StartRemote (var control: longint): longint; stdcall;
external 'PBRemote.dll' name 'StartRemote';
function GetRemote(): longint; stdcall; external 'PBRemote.dll' name
'GetRemote';

When I send a value '2' to the StartRemote function, it returns back
the number 1,242,552. It should have sent back a '2'. This leads me to
believe there is a problem with my interface. How can I fix this?

Here's the interface of the VB Component I'm calling:
Declare Function StartRemote Lib "PBRemote.dll" (ByVal CommPort As
Long) As
Long
Declare Function GetRemote Lib "PBRemote.dll" () As Long

Can anyone give me some suggestions on why this is failing in Delphi.
Thanks,
-Shawn
Back to top
Messtechnik Beratung
Guest





PostPosted: Sun Dec 14, 2003 1:09 pm    Post subject: Re: Help writing interface to VB Dll - Not Correctly Sending Reply with quote





Shawn Call wrote:

Quote:
I'm trying to interface a VB DLL to Delphi. I wrote the interface, but
found it was not sending the long data type correctly to the VB
Component. I worked with the DLL developer, who recompiled the code to
send me back what it received, that's when I discovered the data was
not coming across correctly.

Here's my interface code:
implementation
function StartRemote (var control: longint): longint; stdcall;
external 'PBRemote.dll' name 'StartRemote';
function GetRemote(): longint; stdcall; external 'PBRemote.dll' name
'GetRemote';

When I send a value '2' to the StartRemote function, it returns back
the number 1,242,552. It should have sent back a '2'. This leads me to
believe there is a problem with my interface. How can I fix this?

Here's the interface of the VB Component I'm calling:
Declare Function StartRemote Lib "PBRemote.dll" (ByVal CommPort As
Long) As
Long
Declare Function GetRemote Lib "PBRemote.dll" () As Long

Can anyone give me some suggestions on why this is failing in Delphi.
Thanks,
-Shawn

Hi Shawn,
try

Declare Function StartRemote Lib "PBRemote.dll" (ByRef CommPort As Long)
As Long

or remove var at

function StartRemote (__var__ control: longint): longint; stdcall;

Sincerly

Gerhard



Back to top
Shawn Call
Guest





PostPosted: Mon Dec 15, 2003 1:19 am    Post subject: Re: Help writing interface to VB Dll - Not Correctly Sending Reply with quote



Thanks! Removing "var" from the following fixed the problem!!

function StartRemote (control: longint): longint; stdcall;

Messtechnik Beratung <messtechnik_beratung (AT) web (DOT) de> wrote

Quote:
Shawn Call wrote:

I'm trying to interface a VB DLL to Delphi. I wrote the interface, but
found it was not sending the long data type correctly to the VB
Component. I worked with the DLL developer, who recompiled the code to
send me back what it received, that's when I discovered the data was
not coming across correctly.

Here's my interface code:
implementation
function StartRemote (var control: longint): longint; stdcall;
external 'PBRemote.dll' name 'StartRemote';
function GetRemote(): longint; stdcall; external 'PBRemote.dll' name
'GetRemote';

When I send a value '2' to the StartRemote function, it returns back
the number 1,242,552. It should have sent back a '2'. This leads me to
believe there is a problem with my interface. How can I fix this?

Here's the interface of the VB Component I'm calling:
Declare Function StartRemote Lib "PBRemote.dll" (ByVal CommPort As
Long) As
Long
Declare Function GetRemote Lib "PBRemote.dll" () As Long

Can anyone give me some suggestions on why this is failing in Delphi.
Thanks,
-Shawn

Hi Shawn,
try

Declare Function StartRemote Lib "PBRemote.dll" (ByRef CommPort As Long)
As Long

or remove var at

function StartRemote (__var__ control: longint): longint; stdcall;

Sincerly

Gerhard

Back to top
Tony J Hopkinson
Guest





PostPosted: Mon Dec 15, 2003 8:39 pm    Post subject: Re: Help writing interface to VB Dll - Not Correctly Sending Reply with quote

On 13 Dec 2003 20:42:46 -0800, [email]calls (AT) mama (DOT) indstate.edu[/email] (Shawn Call)
wrote:

Quote:
I'm trying to interface a VB DLL to Delphi. I wrote the interface, but
found it was not sending the long data type correctly to the VB
Component. I worked with the DLL developer, who recompiled the code to
send me back what it received, that's when I discovered the data was
not coming across correctly.

Here's my interface code:
implementation
function StartRemote (var control: longint): longint; stdcall;
external 'PBRemote.dll' name 'StartRemote';
function GetRemote(): longint; stdcall; external 'PBRemote.dll' name
'GetRemote';

When I send a value '2' to the StartRemote function, it returns back
the number 1,242,552. It should have sent back a '2'. This leads me to
believe there is a problem with my interface. How can I fix this?

Here's the interface of the VB Component I'm calling:
Declare Function StartRemote Lib "PBRemote.dll" (ByVal CommPort As
Long) As
Long
Declare Function GetRemote Lib "PBRemote.dll" () As Long

Can anyone give me some suggestions on why this is failing in Delphi.
Thanks,
-Shawn

You might want to use the cdecl instead stdcall, cdecl is for
accessing librariries written in C/C++ and it seems likely that VB
would follow the same methodology.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.