How can I call a DLL function with an array as an argument?

Hi all.

I need to call DLL function with an array of long numbers as an argument.

I define this in C++ code as follows:

'#define EXPORT extern "C" __declspec(dllexport)
EXPORT void MyFunc(long *lArgs) {
...
}

How I could call this function from OO Basic?


I do this on Excel VBA very simple:

Public Declare Sub MyFucnd Lib "MyLib.dll" (ByRef lArgs As Long)
  Dim MyArray(3) As Long
  MyArray(0) = Value0
  MyArray(1) = Value1
  MyArray(2) = Value2
  MyFunc MyArray(0)

This code is working on Excel, but not work on OO Basic :frowning:

What is mistake? What should I do?

Thanks.

Alex.

Try this:
(try #1) Public Declare Function MyFucnd Lib “MyLib.dll” (ByRef lArgs As Long) as Long
if it not work, try change the argument so the declaration appear like this:
(try #2) Public Declare Function MyFucnd Lib “MyLib.dll” ( lArgs ) as Long

Hi @Alexander,

Are you getting any kind of error message when you to run your code?

Here’s a note in the Online Help regarding calling-into DLLs: