[Mono-list] Re: Method signature modification

Robert Jordan robertj at gmx.net
Mon Oct 17 16:24:36 EDT 2005

Hi Shankari,

> [...] In fact I dont bother about how my C function
> prototype looks like as it can choose not to use any
> arguments passed to it.

It won't work on Win32, unless you switch to cdecl prototypes.

> My C# function does a Dll import like 
> [DllImport(...)]
> static extern void func (param1, param2);
> Under  normal cases, I would call func(param1,param2)
> from C#.
> But I want to set a flag during this. So, I thought of
> doing it like this.
> The C function implementation remains as it is. But
> Dll import is changed to 
> [DllImport(...)]
> static extern void func (flag, param1, param2);
> C# invocation : func(flag,param1,param2) 

Why so complicated?

Define the C DllImport to match its real parameter list:

static extern void func (param1, param2);

Then define a C# method that takes your additional flag:

public static void func (flag,param1,param2)
   // do something with "flag"
   // call the dll import
   func (param1, param2);


More information about the Mono-list mailing list