Page 1 of 1
Basic stack call to a .dll
Posted: Thu Jan 25, 2007 9:35 pm
by gonzas
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?
Posted: Fri Jan 26, 2007 5:15 pm
by oliverk
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
Posted: Wed Feb 07, 2007 11:55 pm
by mwieder
...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
Greatest Ever
Posted: Thu Feb 08, 2007 2:33 pm
by gonzas
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.
Posted: Thu Feb 08, 2007 8:03 pm
by stevenp
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.
Wrapper?
Posted: Thu Feb 08, 2007 8:21 pm
by gonzas
Can you share an example of a wrapper?
Posted: Thu Feb 08, 2007 8:48 pm
by mwieder
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.
Posted: Mon Feb 12, 2007 5:34 pm
by mvanhoudt
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.
Posted: Thu Nov 06, 2008 7:18 pm
by keyless
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