Solved

Unmanaged DLL: C# variable for C++ char**

Posted on 2009-07-13
2
406 Views
Last Modified: 2012-05-07
Hello.

I'm making an application that works with buffers. I have to call some C++ functions with data pointers as arguments. I'm trying to not use unsafe code.
One of the functions have two parameters of type char*. I've defined on C# two buffers:

byte[] Buffer1 = new byte[SIZE];
byte[] Buffer1 = new byte[SIZE];

On the dllimport I use marshaling:
....
[MarshalAs(UnmanagedType.LPArray)] byte[] buffer1,
[MarshalAs(UnmanagedType.LPArray)] byte[] buffer2,
....

These two buffers are filled by the C++ function.
Two retrieve the data of the buffers, I use another C++ function. This function returns in a parameter the last buffer filled:

void FillBuff(char **Pbuff);

Pbuff is a pointer to one of the byte[] buffers defined above.
The problem is that I don't know how to define a C# to assign the pointer returned by the C++ function and accessing to the buffer's content. I've tried several thigs with no success, some of them dying at compilation time, others at execution time.

Any suggestion?

Thanks in advance
0
Comment
Question by:xmasdeu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 41

Accepted Solution

by:
graye earned 250 total points
ID: 24859078
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question