我用CopyMemory,但是~调用CopyMemory的时候VB死了~高手看下怎么弄Type TrasType
SenderDcID As Long
RecipientsDcID As Long
MsgType As Long
MsgContext As String * 1024
End TypePublic Function EnCodeTrasTypeToByteArray(DcType As TrasType, CodeHo() As Byte)
ReDim CodeHo(LenB(DcType) - 1)
CopyMemory CodeHo(0), DcType, LenB(DcType)
End Function
Public Sub UnCodeTrasTypeToByteArray(ReceiveByte() As Byte, FreeDcDim As TrasType)
CopyMemory FreeDcDim, ReceiveByte(0), LenB(FreeDcDim)
End Sub Dim a As TrasType
Dim b As TrasType
Dim Freeb() As Byte
EnCodeTrasTypeToByteArray a, Freeb
UnCodeTrasTypeToByteArray Freeb, b
SenderDcID As Long
RecipientsDcID As Long
MsgType As Long
MsgContext As String * 1024
End TypePublic Function EnCodeTrasTypeToByteArray(DcType As TrasType, CodeHo() As Byte)
ReDim CodeHo(LenB(DcType) - 1)
CopyMemory CodeHo(0), DcType, LenB(DcType)
End Function
Public Sub UnCodeTrasTypeToByteArray(ReceiveByte() As Byte, FreeDcDim As TrasType)
CopyMemory FreeDcDim, ReceiveByte(0), LenB(FreeDcDim)
End Sub Dim a As TrasType
Dim b As TrasType
Dim Freeb() As Byte
EnCodeTrasTypeToByteArray a, Freeb
UnCodeTrasTypeToByteArray Freeb, b
Public Sub UnCodeTrasTypeToByteArray(ReceiveByte() As Byte, FreeDcDim As TrasType)
CopyMemory ByVal VarPtr(FreeDcDim), ByVal VarPtr(ReceiveByte(0)), LenB(FreeDcDim)
End Sub