VB 长整型和字节数组的转换问题 (Long<>Byte)
Posted by JiaJia 17 March,2009
(0)Comment
用到的API声明:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any,Source As Any,ByVal Length As Long)
Long2Byte
@H_301_18@ Dim TempLng As Long
Dim TempBytes( 0 To 3 ) As Byte
TempLng = 2000
#If 方法1 Then
CopyMemory TempBytes( 0 ),TempLng, 4
#ElseIf 方法2 Then
TempBytes( 0 ) = TempLng And &HFF
TempBytes( 1 ) = (TempLng And &HFF00 &) / &H100
TempBytes( 2 ) = (TempLng And &HFF0000 ) / &H10000
TempBytes( 3 ) = (TempLng And &H7F000000 ) / &H1000000 Or (((TempLng And &H80000000 ) <> 0 ) And &H80 )
#End If