What would be the most efficient way to copy the contents of a "Type" (a record structure).
Apparently "RtlMoveMemory" does not work under all circumstances as in the following example:
I find that not every single record field is copied.Code:Public Declare Sub CopyMemory Lib "kernel32.dll" _ Alias "RtlMoveMemory" ( _ Destination As Any, _ Source As Any, _ ByVal Length As Long) Public Type myRecord daKey As Byte daTime As Date daValue As Long End Type Private Sub copyRecords() Dim r1 As myRecord, r2 As myRecord With r2 .daKey = 1 .daTime = CDate("05:23:31") .daValue = 1723 End With Call CopyMemory(r1, r2, Len(r1)) End Sub
(I guess the problem has to do with aligning data to DWORD boundaries?)
So what would be the most efficient (and secure) way to copy the contents of a type?
(Especially if there are many record fields it might be quite hard to copy every single record field with an assignment.)




Reply With Quote