Hey betterLateThanNever,
i tried an example similar to yours and i can get it to work. i can also use a pointer to an integer and get that integer value out. i can even pass a pointer to structure and get the pointer from in the structure to a string to work. BUT, i cant get an array of pointers to work. for some reason the RtlMoveMemory doesnt copy the values in my array correctly when called from powerbuilder but it works in C++.
typedef struct numStructTag{
char* aString;
char* bString;
int num;
}numStruct;
//working integer pointer
void* pbIntArrayPtr;
int* myInt = new int;
pbArrayTest(pbIntArrayPtr);
cout << "pbIntArrayPtr: " << pbIntArrayPtr << endl;
RtlMoveMemory(myInt, pbIntArrayPtr, (sizeof(int)) );
cout << "myInt: " << *myInt << endl;
//end working integer pointer
//working code for array of structs!
numStruct* numStrArr[10];
numStruct* numStrValPtr = new numStruct;
int* intValPtr = new int;
char* tempStra = new char[256];
char* tempStrb = new char[256];
void* numStrArrPtr;
fillIntArray(numStrArrPtr);
RtlMoveMemory(numStrArr, numStrArrPtr, (sizeof(int)*(10) ) );
for(int j = 0; j < 10; j++){
void* tempPtr = (int*)numStrArr[j];
RtlMoveMemory(numStrValPtr, tempPtr, (sizeof(int)*3) );
cout << "numStrValPtr = " << numStrValPtr->num << endl;
void* tempPtrStr = (char*)numStrValPtr->aString;
RtlMoveMemory(tempStra, tempPtrStr, (sizeof(char)*(256) ) );
cout << "tempStra = " << tempStra << endl;
tempPtrStr = (char*)numStrValPtr->bString;
RtlMoveMemory(tempStrb, tempPtrStr, (sizeof(char)*(256) ) );
cout << "tempStrb = " << tempStrb << endl << endl << endl;
}
//end of working code
but when i try to do something simple in power builder for an array of pointers to integers it craps out. the following code prints to a file the values in the array after ive done a move. i did this to compare the values to the allocated addresses in the dll. a call to the dll from another c++ app shows the address values match. but in powerbuilder they dont.
any arrptr
long val
long intArray[]
long size
arrptr = 0
size = pbArrayTest(arrptr)
MessageBox("size is: ", String(size))
int j
for j = 1 to size
intArray[j] = 0
next
RtlMoveMemoryMoveArray(intArray, arrptr, (4 * size) )
int handle
handle = FileOpen("c:\temp\dllInfo.txt", LineMode!, Write!)
MessageBox("handle", String(handle))
FileWrite(handle, "rcvd arrptr as: " + String(arrptr))
for j = 1 to size
FileWrite(handle, String(intArray[j]))
next
RtlMoveMemoryMoveInt(val, intArray[1], (4) )
MessageBox("value in firstPtr (should equal file): ", String(val) + "~n value of arrPtr: " + String(arrptr))
FileClose(handle)
FUNCTION long pbIntPtrTest(REF long ptr) Library"pbtestdll.dll"
SUBROUTINE RtlMoveMemoryMoveInt(REF long dest, long source, long al ) library 'kernel32.dll' ALIAS for "RtlMoveMemory"
SUBROUTINE RtlMoveMemoryMoveArray(REF long dest[],REF any source, long al ) library 'kernel32.dll' ALIAS for "RtlMoveMemory"
SUBROUTINE RtlMoveMemoryMoveStruct(REF struct1 dest, REF long source, long al ) library 'kernel32.dll' ALIAS for "RtlMoveMemory"
SUBROUTINE RtlMoveMemoryMoveString( string dest, REF long source, long al ) library 'kernel32.dll' ALIAS for "RtlMoveMemory"
FUNCTION long pbArrayTest(REF any ptr) Library"pbtestdll.dll"
have you got any suggestions or ideas as to what the heck im doing wrong?
thanks for your help already...ive learned a lot from your sample.
txjump