gpt4 book ai didi

c++ - VB.NET 错误 "Value of type ' Ushort' cannot be converted to 'Ushort()' "从 native C++ DLL 读取二维字节数组

转载 作者:太空宇宙 更新时间:2023-11-04 12:56:25 26 4
gpt4 key购买 nike

我收到 VB 错误:“‘Ushort’类型的值无法转换为‘Ushort()’”。

我有一个 VB.NET Windows 应用程序调用 native (C++) DLL 中的函数,以从 DLL 中的页面数组中读取特定的 256 字节页面。

函数的 DLL 源中的 VISUAL-C++ 声明....

extern "C" BASICDLL_API int __stdcall My_Read_High_Speed_Data(unsigned char ptr, unsigned short *buf)
{
return BDLL_ReadBlock(0x00300000 + ptr, (unsigned char *)buf);
}

DLL 中函数的 VB.NET 声明................................

<DllImport("MyDll.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)>
Public Function My_Read_Parameters(ByVal board As Byte, ByVal params As UShort()) As Int32
End Function

声明 VB.NET 缓冲区以保存来自 DLL 的 64 页,每页 256 字节......

Dim input_page_buffer( 64, 256 ) As UInt16

VB.NET函数从DLL中读取页面......................................

function poll()                         
dim page_index = 1
dim success = My_Read_High_Speed_Data( page_index, input_page_buffer(1, 1) )
end function

最佳答案

dll导入函数

..., ByVal params As UShort()

调用 UShort() 作为第二个参数,而 c++ 有

..., unsigned short *buf)

将 dll 导入更改为 UShort

关于c++ - VB.NET 错误 "Value of type ' Ushort' cannot be converted to 'Ushort()' "从 native C++ DLL 读取二维字节数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46454529/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com