DLL Support

From Flowcode Help
Jump to navigationJump to search

DLLs included with Flowcode

A DLL or Dynamic Link Library is a common way of wrapping a set of software functions up into a library that can be called by an application. They are usually created to allow programs to do certain tasks without having to rewrite the task and re-compile the code each time. In Windows there are DLL calls to allow you to create and control application windows, play and record audio as well as a whole host of other things.

Some of the components that are packaged with Flowcode already come with their own DLL files built in to allow the components to do things like this:


Collect the system time and date - GPS NMEA Data Injector Component

Synthesize speech - Speech Component

Communicate over USB - USB Serial, USB Slave, USB HID

Communicate over MIDI - Midi Component

Communicate over a COM port - COM Port Component

Communicate over a network - TCPIP Base Component

Talk to existing third party hardware - Vellemann KS0108, Pico Scope 2000 series, MIAC USB Slave

Adding your own DLL calls into Flowcode

A DLL can easily be added to your program using the standard macro interface.

Start by placing the DLL file into a known location on your computer. A good place for stable DLL files is inside the "Flowcode v7/Components/DLL" folder or in the same folder as the Flowcode project file for portability.


DLLMacro.jpg


The syntax looks like this - (DLL Function Name) : (DLL Type) [(Path to DLL)]


Example:

ReadTime:DLLs[$(appdir)components/dll/DateTime.dll]


DLL Function name is the name of the function in the DLL you are trying to call, if the call cannot be found then the component debugger window will display the error.

DLL Type is the type of DLL, there is "DLLs" which is a standard type DLL and "DLLc" which is an alternative custom style DLL.

Path to DLL is the file path on your system, [$(appdir)components/dll/DLLNAME.dll] can be used for the Components/DLL directory [$(srcdir)DLLNAME.dll] can be used for the project directory.


If you don't already know the explicit DLL function names then they can be found by using a tool like DLL Export Viewer to see inside the DLL file.


The DLL based macro appears like this in the Project explorer pane.


DLLPane.jpg


The DLL based macro can then be called as part of your program just like any other macro or component macro.

The DLL call can even be wrapped up inside a component macro call as part of the component export process using the Interface manager. By specifying the macro as a simulation macro a user using your exported component can easily see that this is a macro that cannot be downloaded to an embedded target.


DLLFunc.jpg

Creating your own DLLs

You can create your own DLLs to suit your requirements by using free to use applications such as Microsoft Visual Studio.

A guide on creating a DLL in visual studio can be found here: Create a dll
Or a more generic example (resulting DLL is not directly compatible): Walkthrough: Creating and Using a Dynamic Link Library (C++)