I am trying to build a C++ dll with Visual Studio and have the function work in Xojo. The example is created in 64-bit Windows 10, and I can’t seem to get Xojo to recognize that the function is available and to run the example dll. For testing purposes, it is a method called AddTwo, which adds two integers together and returns the sum of these two numbers.
I must be missing something simple. Included is the Visual Studio Code, DLL, and Xojo Code.
Here is the Action Button code:
[code]Declare Function AddTwo Lib “MYMATHDLL.dll” (x as Integer, y as Integer) As Integer
Dim Answer as Integer
If System.IsFunctionAvailable(“AddTwo”, “MYMATHDLL.dll”) Then
Answer = AddTwo(5, 3) //Add 5 + 3
Answer = 0 //Error
TextArea1.Text = TextArea1.Text + "answer: " + Answer.ToText[/code]
This is the C++ MyMathDLL.h file:
#define MYMATHDLL_API __declspec(dllexport)
#define MYMATHDLL_API __declspec(dllimport)
extern MYMATHDLL_API int AddTwo(int x, int y);
Here is the MyMathDLL.cpp code:
[code]// MyMathDLL.cpp : Defines the exported functions for the DLL.
// This is an example of an exported function.
MYMATHDLL_API int AddTwo(int x, int y)
return x + y;
After trying this for a couple of days, its time for me to ask for help.
Here is the Visual Studio 2019 C++ code and Xojo file: MyMathDLL.zip
Thanks for your help,