Void pointer and structure pointer

  • Thread starter Thread starter Nasif
  • Start date Start date
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
 
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.
 
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.
 
Back
Top