Call DLL Function (from Event Handler) Crashes?
Posted: Fri Feb 03, 2017 5:15 pm
I'm attempting to call functions in an external DLL from a button handler in scalc, but LibreOffice crashes at the end of the handler.
I'm not certain what I'm doing incorrectly. The external function calls "succeed" (has the desired effect, returns data, etc.), but at the end of the handler, LO crashes.
Here's the BASIC macro I have.
Am I doing this the proper way? Do I need to FreeLibrary at the end? It crashes with or without it. I tried putting it inside the function making the external call, without meaningful effect. Is there some other setup/teardown I need to do, in general? Are there limitations on event handlers?
Thanks.
I'm not certain what I'm doing incorrectly. The external function calls "succeed" (has the desired effect, returns data, etc.), but at the end of the handler, LO crashes.
Here's the BASIC macro I have.
Code: Select all
Declare Function _myfunc Lib "path\to\my.dll" Alias "myfunc" (ByVal inst as Integer) as Integer
Function myFunc(ByVal x as Integer) as Integer
Dim rc as Integer
rc = _myfunc(x)
myFunc = rc
End Function
Sub ButtonHandler(oEvent)
Print myFunc(0)
FreeLibrary "path\to\my.dll"
End Sub
Thanks.