You need to use the __arglist keyword (which is undocumented), Bart # had a nice blog about it.
Example
class Program { [DllImport("user32.dll")] static extern int wsprintf([Out] StringBuilder lpOut, string lpFmt, __arglist); static void Main(String[] args) { var sb = new StringBuilder(); wsprintf(sb, "%s %s %s", __arglist("1", "2", "3")); Console.Write(sb.ToString()); } }
This is not a standard way to dump vararg methods; most solutions will wrap it in several ways, for example.
[DllImport("MyDll", CallingConvention=CallingConvention.Cdecl)] static extern var MyVarArgMethods1(String fmt, String arg1); [DllImport("MyDll", CallingConvention=CallingConvention.Cdecl)] static extern var MyVarArgMethods2(String fmt, String arg1, String arg2);
Shay erlichmen
source share