Basic stack call to a .dll

Interested adding compiled externals from LiveCode and third parties to your LiveCode projects? This is the place to talk about them.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
gonzas
Posts: 3
Joined: Mon Jun 19, 2006 3:57 pm

Basic stack call to a .dll

Post by gonzas » Thu Jan 25, 2007 9:35 pm

I am trying to create a rev program (revolution 2.6) that will communicate with a check scanning device. The check scanner comes with a .dll called LsApi.dll The read me indicates i have to include LsApi.h and LsApi.lib in my project and then can make function calls. Other than putting a script in the stack startup like

set the externals of me to LsApi.dll

What do i need to do to communicate with the device?

oliverk
Site Admin
Site Admin
Posts: 53
Joined: Mon Feb 27, 2006 2:16 pm
Location: Edinburgh

Post by oliverk » Fri Jan 26, 2007 5:15 pm

Hi Gonzas,

Unless the libeary lsAPi.dll has been built as a Revolution external, you will need to either write your own external to wrap around the dll, or get the source code of the dll and convert it into an external.

Unfortunately Revolution does not support arbitrary dlls because of the need to share data between Revolution scripts and external libraries.

You can test if the dll is an external by setting the externals of the your stack to it, saving the stack, restarting Revolution and then examining the output of the following commands (in the message box, with your stack selected):

Code: Select all

put the externalCommands of this stack & return
put the externalFunctions of this stack after msg
If the output is empty then it probably means you'll need to write your own external.

There is an excellent tutorial on external writing for Revolution online at:

http://www.runrev.com/newsletter/novemb ... etter5.php

With regards to the static library and C Header file, I believe that you would just need to include this in the same folder as the dll in your project, although this may be wrong.

Hope this was some help.

Regards

Oliver
Oliver Kenyon
Software Developer
Runtime Revolution

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Wed Feb 07, 2007 11:55 pm

...but also check out Ken Ray's excellent writeup on how to use non-rev dlls in Windows using vbs:

http://www.sonsothunder.com/devres/revo ... ext002.htm

gonzas
Posts: 3
Joined: Mon Jun 19, 2006 3:57 pm

Greatest Ever

Post by gonzas » Thu Feb 08, 2007 2:33 pm

That is the most complete writeup i have ever seen in any developer forum. Can't tell you how much i appreciated the information. If there is any way i can repay you, let me know. Can't wait to get started.

stevenp
Posts: 26
Joined: Wed Jan 31, 2007 3:29 am

Post by stevenp » Thu Feb 08, 2007 8:03 pm

That tutorial's for an ActiveX DLL. Since your's has a header file and lib then it's just a standard DLL (ex. cdecl). Those types of DLL's are two different things. VBScript can't call standard DLL's. It looks like a wrapper would need to be written.

gonzas
Posts: 3
Joined: Mon Jun 19, 2006 3:57 pm

Wrapper?

Post by gonzas » Thu Feb 08, 2007 8:21 pm

Can you share an example of a wrapper?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Post by mwieder » Thu Feb 08, 2007 8:48 pm

It's true - if the dll isn't an ActiveX control then vbscript won't be able to talk to it. Thank you Microsoft.

Regarding the wrapper functions, check out the GetDriveType example in the externals sdk. I don't know how many functions you have to deal with in your library, but that should give you an idea of what's involved for a simple Windows api call.

mvanhoudt
Posts: 11
Joined: Wed Jul 26, 2006 4:08 pm
Contact:

Post by mvanhoudt » Mon Feb 12, 2007 5:34 pm

It is straightforward to write a Revolution External wrapper for any DLL, refer to Mark Waddingham's write up on how to write externals for Revolution. His article includes a stack that will create an xcode or visual studio project for you, so that all that is required is to write some functions to communicate with the other DLLs.
Marcus van Houdt
Software Developer at Runtime Revolution
marcus@runrev.com

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Thu Nov 06, 2008 7:18 pm

mvanhoudt wrote:It is straightforward to write a Revolution External wrapper for any DLL, refer to Mark Waddingham's write up on how to write externals for Revolution. His article includes a stack that will create an xcode or visual studio project for you, so that all that is required is to write some functions to communicate with the other DLLs.
Mark Waddinghams write up really seems only to explain how to create a wrapper for the one example external, and it seems far from straight forward. His second installment even makes it less straight forward by explaining how limited his first example was. I would love to see a good writeup of how to create a wrapper for a popular 3rd party .DLL

Post Reply

Return to “Using Externals”