您的位置首页百科知识

VB 中CopyMemory的用法

VB 中CopyMemory的用法

的有关信息介绍如下:

VB 中CopyMemory的用法

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)Private Sub Form_Load()Dim A(15) As Byte, B(15) As Byte B(0) = &HAF B(1) = &H82 B(2) = &H25 B(3) = &H74CopyMemory A(0), B(0), 4 '目标厅段贺,源,大小-字节Debug.Print Hex(A(0)), Hex(A(1)), Hex(A(2)), Hex(A(3)), Hex(A(4))End Sub Private Sub Command1_Click() Dim B(15) As Byte B(0) = &HAF B(1) = &H82 B(2) = &H25 B(3) = &H74 iLength = 0 CopyMemory B(4), iLength, 4 Debug.Print B(0), B(1), B(2), B(3), Hex(B(4)), Hex(B(5)), Hex(B(6)), Hex(B(7)) dwOrdinal = 0 CopyMemory B(8), dwOrdinal, 4 Debug.Print B(0), B(1), B(2), B(3), Hex(B(4)), Hex(B(5)), Hex(B(6)), Hex(B(7)), Hex(B(8)), Hex(B(9)), Hex(B(10)), Hex(B(11)) Dim dwCheckSum As Long dwCheckSum = 0 CopyMemory B(12), dwCheckSum, 4End Sub这样应该容易理解了吧~你源内存地址写燃毕的是0 该地址上的扮派第一个字节就是2 所以以你上面的代码来看B数组中的4,8,12元素都是2