[问题] c#要如何引用c++不定参数function呢

楼主: icarus0508 (饕餮)   2014-04-24 11:15:14
大家好
最近应用是想要利用c# 去呼叫 自已写的c++ 不定参数function 如下
void SendCommand(const char* pFunction, ...){}
并且在c#中使用
[System.Runtime.InteropServices.DllImport("RemoteControlDll.dll",
EntryPoint = "SendCommand")]
public static extern void SendCommand(string pFunction, params
string[] Value);
来呼叫该function,但一直会连结不对。
google上也找不太到相关的做法(或是关键字不对?)。
请问各位是否有类似的经验呢? 谢谢
已解决
分享解法:
void foo(my_struct_t x, ...);
C#:
[DllImport("mydll.dll")]
public static extern foo(my_struct_t x, __arglist);
Call from C# as:
foo(x, __arglist(y, z));
这样才对 谢谢
作者: dontblame (占卜师)   2014-04-26 09:37:00
推分享

Links booklink

Contact Us: admin [ a t ] ucptt.com