DllImport for C# (original is in C++/CLI) Need to output arrays

Go To StackoverFlow.com

1

This is how it looks like in C++:

[DllImportAttribute("Win32DLLRecon.dll", CharSet=CharSet::Auto, CallingConvention=CallingConvention::StdCall)]
    extern "C" void proc1
        (__int32 *i1,
             __int16 *i2,
             __int16 *i3,
             char *i4,
             unsigned *i5,      
             unsigned char *o1, 
             unsigned __int16 *o2,
             float *o3); 

where i = input , o = output What would be C# equivalent?
I tried to specify like arrays, for example "out Byte [] output", but it complains that it needs byte*, not byte[] ( I do need to use pointers at the code). EDIT: What will happen if I just declare my whole class as unsafe and pass these as pointers: extern proc (out Byte* output, etc)?

2012-04-05 00:22
by user1298416
The argument names and comments were carefully crafted to not get you an answer - Hans Passant 2012-04-05 07:08
I modified the names, hopefully it is more clear now - user1298416 2012-04-05 12:25
Please, can someone take a look!! - user1298416 2012-04-05 13:46


0

I believe that you need to use a System.IntPtr for this, or a System.IntPtr[] for a true array.

2012-04-05 00:29
by Justin Pihony
Can I use it for Byte and SByte? Do you have any examples? What will happen if I just declare my whole class as unsafe and pass these as pointers: extern proc (out Byte* output, etc) - user1298416 2012-04-05 00:39
Ads