Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
stefan_schnell
Active Contributor
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.
'-Begin-----------------------------------------------------------------
'-
'- FreeBasic Dynamic Link Library (DLL) for GuiXT
'- Compile it with -dll option.
'-
'- Author: Stefan Schnell
'-
'-----------------------------------------------------------------------

'-Includes------------------------------------------------------------
#Include Once "windows.bi"

Extern "Windows-MS"

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

'-Variables-----------------------------------------------------
Dim resMsgBox As Long

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

End Function

End Extern

'-End-------------------------------------------------------------------

 

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

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

//-End------------------------------------------------------------------

 

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

EndProcedure

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

 

Labels in this area