Basic stack call to a .dll
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Basic stack call to a .dll
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?
set the externals of me to LsApi.dll
What do i need to do to communicate with the device?
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):
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
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
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
Software Developer
Runtime Revolution
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
...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
http://www.sonsothunder.com/devres/revo ... ext002.htm
Greatest Ever
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.
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
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.
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.
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
Software Developer at Runtime Revolution
marcus@runrev.com
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 .DLLmvanhoudt 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.