User Guide

Ruby Component
External DLLs
You can call functions in external DLLs from inside your Ruby code. This is done by making use of the Ruby Win32API extension.
All you do is create an instance of the Win32API class that has all the information about the function call you want to make. You then execute
the Win32API call method to execute the function. All very straightforward.
Let's take a look in detail about how this is all achieved.
The Win32API Extension
The key to providing access to external DLLs is the Win32API extension. This is installed in your FlowBotics Studio folder in Program Files
under \ruby\libraries\win32.
The files are separate from the software but FlowBotics Studio knows where to look for them on your PC. If you are only ever working on the
same machine then you don't have to worry about any of this.
However, if you create an exported exe that uses the extension and want to pass this to someone else then either they will need to have
FlowBotics Studio installed on their system or you will have to distribute the \ruby\libraries\win32 folder (including the ruby and libraries
parent folders).
The ruby parent folder should then be inside the same folder and at the same level as your exported exe as shown in the picture below:
The first thing you need to do is tell Ruby you want to use the Win32API extension. This is done by calling the Kernel method require:
require "Win32API"
Creating a Function Object
Before you can call a function in an external DLL you need to create an instance of the Win32API class. The resulting object must have all
the information it needs about the target function before it can be used to make the call.
To create a Win32API object:
callObject = Win32API.new( library, functionName, inTypes, outType )
The input parameters (shown in italics above) are as follows:
library
This is the name of the dll that contains the function you want to call. You don't need to add the .dll file extension so you can leave that off if
you wish. If you don't specify a path then the software will look for the dll in the following places:
the folder from which the application executed
the current folder
the Windows system folder (e.g. c:\windows\system or system32)
the Windows folder
the folders that are listed in the PATH environment variable
functionName
159 of 212