问题描述
调用PInvoke函数CopyMemory;堆栈不平衡。这很可能是因为托管PInvoke签名与非托管目标签名不匹配。检查PInvoke签名的调用约定和参数是否与目标非托管签名匹配。
这里是我的代码
私有声明Sub CopyMemory Lib" Kernel32"别名RtlMoveMemory (ByRef Destination As Object,ByRef Source As Object,ByVal numbytes As Long)
公共函数BytesToDouble(ByVal TheArray()As Byte)As Double
'此函数将8个字节的数组合并为一个Double数字 - 格式Little Endian
Dim TempLong As Double
Call CopyMemory( TempLong,TheArray(LBound(TheArray)),8)
BytesToDouble = TempLong
结束功能
A call to PInvoke function CopyMemory; has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
here is my code
Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" (ByRef Destination As Object, ByRef Source As Object, ByVal numbytes As Long)
Public Function BytesToDouble(ByVal TheArray() As Byte) As Double
'This function combines array of 8 bytes to a Double number - Format Little Endian
Dim TempLong As Double
Call CopyMemory(TempLong, TheArray(LBound(TheArray)), 8)
BytesToDouble = TempLong
End Function
推荐答案
这篇关于检测到pinvoke堆栈不平衡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!