Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Nov 21, 2019 1:38 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: External method in Windows DLL
PostPosted: Sun Oct 09, 2011 10:29 am 
Offline

Joined: Sun Oct 09, 2011 10:14 am
Posts: 10
Although I would assume that my question is standard, I could not find an answer via Google or through the examples included with RealStudio.
So here we go...

I am trying to use a function implemented in a Windows DLL.
For this I declare an external method. In general this works (other functions work ok) but there is one external function that I cannot get to work. This function "returns" a value not only as a standard return value but also modifies a variable in the function call.

This is the function as defined for Visual Basic:
Function USB_Read Lib "USB.dll" (ByVal handle As Long, ByVal block_index As Long, ByVal buffer512 As Any) As Long


So besides a return value (error code) from the function, the actual content is returned in bufer512

In RealStudio I have implemented this as:
Declare Function USB_Read Lib "USB.dll" Alias "USB_Read" (ByVal handle As int32, ByVal block_index As int32, ByVal buffer512 As Ptr) as int32


In the application I call the function as follows:

dim usbString as MemoryBlock
dim n as int32

usbString = new MemoryBlock(512)

n = USB_Read(handleUSB, 0, usbString.Ptr(0) )


note: the handleUSB is an int32 that was obtained by another external function that returns the handle (this works correct).

I then try to get the value that was returned by:
TextField1.Text = dongleString.StringValue(1,20)


but it remains empty...
I assume I am not doing this correctly?

Any help would be great.


Top
 Profile  
Reply with quote  
 Post subject: Re: External method in Windows DLL
PostPosted: Sun Oct 09, 2011 4:39 pm 
Offline

Joined: Mon Sep 22, 2008 9:01 pm
Posts: 61
Quote:
dim usbString as new MemoryBlock(512)
dim n as int32

n = USB_Read(handleUSB, 0, usbString )


Top
 Profile  
Reply with quote  
 Post subject: Re: External method in Windows DLL
PostPosted: Sun Oct 09, 2011 4:39 pm 
Offline

Joined: Mon Sep 22, 2008 9:01 pm
Posts: 61
err, try that instead


Top
 Profile  
Reply with quote  
 Post subject: Re: External method in Windows DLL
PostPosted: Thu Oct 13, 2011 11:23 am 
Offline

Joined: Sun Oct 09, 2011 10:14 am
Posts: 10
Yes: that did it!
Thanks.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group