How to marshal managed array to DLL.

A

Ananas

Hi,

I'm using C# and C++ DLL. I need to send an array of unknown size at
compilation time to C++ native code. How to do this.

Example;

C#:
byte[] Image = ImageLoadFromFile(FileName); // as like the dynamic
image in the C++, for example, image loads from the file at the run
time.

C++:
void GetImage(unsigned char *Img, unsigned int size);

How to declare GetImage in C# for to recieve and read array in C++
correct?

Thanks in advise,
Eugene.
 
W

Willy Denoyette [MVP]

Ananas said:
Hi,

I'm using C# and C++ DLL. I need to send an array of unknown size at
compilation time to C++ native code. How to do this.

Example;

C#:
byte[] Image = ImageLoadFromFile(FileName); // as like the dynamic
image in the C++, for example, image loads from the file at the run
time.

C++:
void GetImage(unsigned char *Img, unsigned int size);

How to declare GetImage in C# for to recieve and read array in C++
correct?

[DllImport("....")]
extern static void GetImage(byte[] img, int size);

Willy.
 
A

Ananas

Thanks.

"""Willy Denoyette [MVP] ÐÉÓÁÌ(Á):
"""
Ananas said:
Hi,

I'm using C# and C++ DLL. I need to send an array of unknown size at
compilation time to C++ native code. How to do this.

Example;

C#:
byte[] Image = ImageLoadFromFile(FileName); // as like the dynamic
image in the C++, for example, image loads from the file at the run
time.

C++:
void GetImage(unsigned char *Img, unsigned int size);

How to declare GetImage in C# for to recieve and read array in C++
correct?

[DllImport("....")]
extern static void GetImage(byte[] img, int size);

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top