请问, 为何Integer在内存中占用4字节? CopyMemory数据出错
Herro 2004-01-16 09:01:27 很奇怪, 百思不得其解.
代码如下
Public Type BITMAPFILEHEADER
bfType As Integer 'must be 19778 = "BM"
bfSize As Long 'size of file in bytes LOF(%bf)
bfReserved1 As Integer 'Reserved must be set to zero
bfReserved2 As Integer 'Reserved must be set to zero
bfOffBits As Long 'the begining of the actual bmp data
End Type
Private m_bfh As BITMAPFILEHEADER
CopyMemory m_bfh, Stream(0), Len(m_bfh) 'stream是图像的数据流
结果m_bfh.bfReserved2的数据是bfOffBits的.
我看了下m_bfh的内存, 发现如果用Get #1,,m_bfh得到的数据是
42 4D 00 00 36 5A 09 00 00 00 00 00 36 00 00 00 ; BM..6Z......6...
占用了16位也! 当然len得出来是14.
而且m_bfh.bfSize的指针也确实指向36 5A
而从stream CopyMemory 进去的是
42 4D 36 5A 09 00 00 00 00 00 36 00 00 00 ; BM6Z......6...
这才是正确的源图像文件数据啊...
好像只有这个自定义类型有这种问题, 请问发生的原因和解决方法?
先谢了.