• Welcome to Theos PowerBasic Museum 2017.

The PB-methode: @pointer[n] inside a C++-DLL????

Started by Heinz Grandjean, December 23, 2014, 09:55:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Heinz Grandjean

Hello community!
Sending arrays of a PB-type to a function inside a PB-DLL I normally send the pointer of array(0).
Inside the DLL I can access all the elements by using @ptr[n]= ...
I'm looking for a method to use the same technique while linking to C++-DLL.
The linking in itself is ok. It is not the topic of my question!
Let me show some code-snippets:

TYPE myType
      var1 AS LONG
      Var2 AS LONG

DIM myTest(255) AS myType

DECLARE FUNCTION myC_Function CDECL ALIAS "myC_Function" _
         ( _
         BYVAL myTest PTR _

CALL DWORD myC_address USING myC_Function _
      ( _
      VARPTR(myTest(0)) _

C+++ Side:

// Declares:
struct mytest
    unsigned long Var1;
unsigned long Var2;
mytest mytest_arr[255];

#define C_EXPORT extern "C" __declspec(dllexport)
C_EXPORT long C_mytest (

long C_mytest
mytest *pmytest_arr
   mytest_arr[0] = *pmytest_arr; //as far as I have tested: this is OK!?

   /*The question now, how to fill mytest_arr[1 to 254] according to the
    PB-practice "mytest_arr[1] = @pmytest_arr[1]" etc.?

Maybe there is an idea?
Merry Christmas to you all!
Frohe Weihnachten!

Heinz Grandjean

Heinz Grandjean

Problem solved.
"MoveMemory" does the job!

Heinz Grandjean

Frederick J. Harris

I'm really sorry I missed your post Heinz.  I didn't see it until about 12/30.  I usually check every other day or so, but the holidays threw me off. 

Glad you found a solution though.  MoveMemory(), along with  a lot of the msvcrt functions, are useful.