P / Invoke回调与变量参数

时间:2013-06-16 07:44:36

标签: vb.net callback dllimport variadic-functions

.h文件包含以下签名:

typedef void (RTMP_LogCallback)(int level, const char *fmt, va_list);
void RTMP_LogSetCallback(RTMP_LogCallback *cb);

我想在VB.NET应用程序中使用它,所以我尝试了这种方式:

<DllImport("librtmp.dll", CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub RTMP_LogSetCallback(cb As LogCallback)
End Sub

<UnmanagedFunctionPointer(CallingConvention.Cdecl)>
Public Delegate Sub LogCallback(level As LogLevel, message As String, args As IntPtr)

...

Private m_LogCallback As New LibRtmp.LogCallback(AddressOf LogCallback)
Private Sub LogCallback(lvl As LibRtmp.LogLevel, message As String, args As IntPtr)
    Console.WriteLine(message)
End Sub

args包含一个似乎是参数数组指针的整数。

如何从该数组中获取值?

0 个答案:

没有答案