471,349 Members | 1,236 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 software developers and data experts.

Void pointer and structure pointer

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
Jun 27 '08 #1
3 5324
Nasif wrote:
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.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jun 27 '08 #2
Hi

For a pointer to a struct there is a "Structures Sample" see
http://msdn2.microsoft.com/en-us/lib...kz(VS.80).aspx

regards
Martin
Jun 27 '08 #3
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.
"Martin Koch" wrote:
Hi

For a pointer to a struct there is a "Structures Sample" see
http://msdn2.microsoft.com/en-us/lib...kz(VS.80).aspx

regards
Martin
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Stig Brautaset | last post: by
8 posts views Thread by Luc Le Blanc | last post: by
52 posts views Thread by Douglas Garstang | last post: by
188 posts views Thread by infobahn | last post: by
9 posts views Thread by Juggernaut | last post: by
27 posts views Thread by Erik de Castro Lopo | last post: by
24 posts views Thread by Rob Hoelz | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.