[Progress Communities] [Progress OpenEdge ABL] Forum Post: RE: byte array to memptr

Status
Not open for further replies.
G

goo

Guest
sorry… but after looking at the code, I saw suddenly that it did not check for ProcessBitness… Fix… METHOD PUBLIC STATIC "System.Byte[]" MemptrToByteArray( pmptr AS MEMPTR ): DEFINE VARIABLE oIntPointer AS System.IntPtr NO-UNDO . DEFINE VARIABLE iPtr64 AS INT64 NO-UNDO . DEFINE VARIABLE vInt AS INT NO-UNDO . DEFINE VARIABLE iPtr32 AS INTEGER NO-UNDO . DEFINE VARIABLE nBytes AS "System.Byte[]" . vInt = GET-SIZE (pmPtr). nBytes = NEW "System.Byte[]" (vInt). IF oo.DataHelper.SessionHelper:processBitness() = 32 THEN DO : iPtr32 = GET-POINTER-VALUE (pmptr) . oIntPointer = NEW System.IntPtr (iPtr32). END . ELSE DO : iPtr64 = GET-POINTER-VALUE (pmptr) . oIntPointer = NEW System.IntPtr (iPtr64). END . System.Runtime.InteropServices.Marshal: Copy (oIntPointer, nBytes, 0 , vInt). RETURN nBytes. FINALLY : /* nPtr = ?.*/ DELETE OBJECT oIntPointer. SET-SIZE (pmPtr) = 0 . nBytes = ?. END . END METHOD .

Continue reading...
 
Status
Not open for further replies.
Top