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:
PB-Side
'Declaration:
TYPE myType
var1 AS LONG
Var2 AS LONG
END TYPE
'Later:
DIM myTest(255) AS myType
'Declares:
DECLARE FUNCTION myC_Function CDECL ALIAS "myC_Function" _
( _
BYVAL myTest PTR _
)
'Later:
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];
//Export-declare:
#define C_EXPORT extern "C" __declspec(dllexport)
C_EXPORT long C_mytest (
mytest*
);
//Function:
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
Problem solved.
"MoveMemory" does the job!
Thanks,
Heinz Grandjean
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.