Skip to Content
Technical Articles
Author's profile photo Stefan Schnell

Tip: How to Code a GuiXT Conformable Dynamic Link Library (DLL)

I show here an example how to call the Windows API function ShellExecute inside a GuiXT script. You can call a DLL function with the command Call, look here for the technical documentation. And now I show an example, how to code your own dynamic link library (DLL) with FreeBASIC to use it inside a GuiXT script.As you can see, in the section “Calling a dll function” in the technical documentation from Synactive, the Call function from GuiXT needs only pointer to strings as input and output arguments. With this knowledge I implement a DLL in FreeBASIC with one export function expMsgBox. These export function has only string arguments, two input and one output. Inside the export function I call a simple MessagBox function with the input parameters. The result of the MessageBox function I convert to a string and put it to the output argument.

'- FreeBasic Dynamic Link Library (DLL) for GuiXT
'- Compile it with -dll option.
'- Author: Stefan Schnell

    #Include Once ""

  Extern "Windows-MS"

    '-Function expMsgBox------------------------------------------------
      Function expMsgBox Alias "expMsgBox" (ByVal inMsg As String, _
        ByVal inTitle As String, ByVal outRes As String) As Long Export

          Dim resMsgBox As Long

        resMsgBox = MessageBox(NULL, inMsg, inTitle, MB_YESNOCANCEL)
        outRes = Str(resMsgBox)
        expMsgBox = resMsgBox

      End Function

  End Extern



I call this DLL function from GuiXT with the following script:


  Call "expMsgBox" dll="FreeBasic.dll" In="Hello World" In="GuiXT" Out="res"
  Message "&[res]"



It works perfect with GuiXT.




With this possibility you can combine the power of GuiXT script with the power of FreeBASIC. GuiXT is standard part of the SAP GUI for Windows installation and FreeBASIC is a free/open source compiler.

15/11/25 Addition

This example above is originated with FreeBasic 0.90. With higher compiler versions the example don’t work anymore, so it is not recommended. Here an equivalent PureBasic example:

; Begin-----------------------------------------------------------------
; PureBasic Dynamic Link Library (DLL) for GuiXT
; Author: Stefan Schnell
; ----------------------------------------------------------------------

  ; Function expMsgBox--------------------------------------------------
    ProcedureDLL.i expMsgBox(inMsg.s, inTitle.s, *outRes)

      ; Variables-------------------------------------------------------
        Protected resMsgBox.i

      resMsgBox = MessageRequester(inTitle, inMsg, #PB_MessageRequester_YesNoCancel)
      PokeS(*outRes, Str(resMsgBox))
      ProcedureReturn resMsgBox


; End-------------------------------------------------------------------


Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.