tags:

views:

154

answers:

1

I have a dll with following signature in C++. It is working in c++;

    void Decompress(unsigned char *in,int in_len,unsigned char * out,
unsigned *o_len,int *e);

Description of parameter

  1. *in : It is byte array passed to fucntion.
  2. in_len : Length of bytes in first parameter.
  3. *out : This would be the output as byte array.
  4. *o_len : No of bytes in third parameter
  5. *e : Error code returned

How can i call it from c#?

What would be the P/Invoke declration?

+2  A: 
static extern void Decompress(
                byte[] input, 
                int in_len,
                byte[] output, 
                ref int o_len,
                out int e);
leppie
How would byte[]output get marshalled to the correct size? Something seems missing here for the marshaller.
TomTom
Thanks. You saved my life :)
Manjoor
@TomTom: it's just a pointer, iow `sizeof(void*)`.
leppie
could you tell me how i could call a static function which is part of a class?QWidget::grabKeyboard ()
Evans
if the class you are refering is a static then you can call it directly classname likeQWidget.grabKeyboard (). if the class is not a static you have to create any one object of that class before calling it (using same syntax).
Manjoor