我正在尝试将C ++ API转换为VB.Net,但这个功能太难了,我不知道它是如何工作的。
以下是此功能的API文档:
void RemoteDllSetReceiver(void *inst, on_received_buffer_t received_buf_cb);
设置回调函数以接收来自DLL的通知。回调的原型是:
typedef bool (*on_received_buffer_t)(void* inst, const unsigned char *buffer, unsigned int size);
其中
注意:通知可能会到达不同的线程(例如网络,计时器,音频)。
我无法想象我用on_received_buffer_t做什么,它必须是委托吗?就像你可以阅读,这个函数返回DLL的通知,如连接状态,用户ID ......
任何帮助将不胜感激,谢谢。
答案 0 :(得分:0)
我必须补充说我正在使用Visual Studio 2008和Compact Framework 3.5。我目前的工作是:
P / Invoke功能:
Private Declare Function RemoteDllSetReceiver Lib "remote_dll.dll" (ByVal inst As IntPtr, ByVal received_buf_cb As on_received_buffer_t) As Integer
委托给receive_buffer_t
Public Delegate Function on_received_buffer_t(ByVal inst As IntPtr, ByVal buffer() As Byte, ByVal size As Long) As Boolean
我在我的代码中称呼它:
RemoteDllSetReceiver(IntPtr.Zero, AddressOf ReceiveMessage)
ReceiveMessage功能:
Public Shared Function ReceiveMessage(ByVal inst As IntPtr, ByVal buffer() As Byte, ByVal size As Long) As Boolean
MsgBox(buffer.ToString())
End Function
由于