Void pointer and structure pointer

N

Nasif

Dear All

I am using a C++ DLL which has two function , one returns a void
pointer, other returns a pointer to structure .But I doing my project
on C#.
Which data types in C# should I use to catch the void pointer and
pointer to structure?
Please answer.

Thanks in advance
Nasif
 
L

Lasse Vågsæther Karlsen

Nasif said:
Dear All

I am using a C++ DLL which has two function , one returns a void
pointer, other returns a pointer to structure .But I doing my project
on C#.
Which data types in C# should I use to catch the void pointer and
pointer to structure?
Please answer.

Thanks in advance
Nasif

Use IntPtr for both.

I assume "void pointer" is just a pointer to something in memory,
because then you can just as easily just handle this as a pointer to byte.
 
V

vladimir

Hi Martin, mentioned sample do not solve the problem where dll function
return result as pointer to structure. The usual situation in C dll:

MY_STRUCT * mystruct;
mystruct = AllocateInternalStruct();// this is function in C dll library
DoSomeAction(params...);// dll function change struct values (possible read
from file, communicate, etc)
....
now, application processes changed values in mystruct-->somevalue
....
DealocateInternalStruct();// dll function

In this case, the InteropServices and Marshal fails (as I know, Marshal
operation returned some as "Structure can not be class of values"). I have
not solved this problem.
 

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