Understanding the Synergy DLL API

The Synergy DLL API enables you to integrate DLLs into your application. A DLL (dynamic link library) is a library of executable functions or data that your Windows-based application can call during execution.

On Windows, DLL files usually have one of the following extensions: .dll, .exe, .drv, or .fon. On Unix, DLLs always have the extension .so.

You can either write your own DLL from scratch or acquire one of the many existing DLLs from an external source.

Important

DLLs created with Visual Basic are not accessible by Synergy. Synergy can only access DLLs written in a language that can create standard (non-ActiveX) DLLs.

Important

A .ALIGN directive should be precede any set of ints or D_ADDR parameters passed to the DLL API. 64-bit and Unix platforms require that numeric types and pointers (D_ADDR) be aligned natively.

To integrate a DLL into your application,

1. Create or otherwise acquire a DLL. Refer to your operating system documentation for more information about creating a DLL.
2. If you’ve created a new DLL, explicitly export the routines that your Synergy program will call. How you export the routines depends on which tool you used to create it. Refer to the documentation for your development tool for instructions.
3. Write a routine that uses the Synergy %DLL_ functions to access the routines in the DLL. (Note that we recommend using the DllImport attribute instead of %DLL_NETCALL; see the %DLL_NETCALL Discussion for more information.)

Let’s say we want to add a splash screen to our application. Our routine might look like this:

;Notepad must be opened to a new document for this sample to work
main
record
    user32, d_addr
    result, d_addr
endrecord

proc
    user32 = %dll_open("user32.dll")
    ;Find the Notepad window
    result = %dll_call(user32, DLL_TYPE_WINAPI,"FindWindowA", "Notepad", "Untitled - Notepad") 
                ;FindWindowA returns a window handle if succeeded, or null if failed
    ;Set the window's title text
    result = %dll_call(user32, DLL_TYPE_WINAPI,"SetWindowTextA", result, "Synergy Rules!") 
                ;SetWindowTextA returns a non-0 value if succeeded, or 0 if failed
    %dll_close(user32)
endmain