473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 5441
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Stig Brautaset | last post by:
Hi group, I'm playing with a little generic linked list/stack library, and have a little problem with the interface of the pop() function. If I used a struct like this it would be simple: ...
8
by: Luc Le Blanc | last post by:
I have 2 APIs that store/recall a void *. Since all I need to store is a 32-bit struct, I pass the actual data (instead of a pointer to it) as a void *: typedef { UInt8 color;...
52
by: Douglas Garstang | last post by:
I can't believe I've been trying to work this out for hours now, and I can't believe I couldn't find someone asking for a similar solution in the newsgroups. No wonder I hate C so much, and every...
188
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
9
by: Juggernaut | last post by:
I am trying to create a p_thread pthread_create(&threads, &attr, Teste, (void *)var); where var is a char variable. But this doesnt't work, I get this message: test.c:58: warning: cast to pointer...
16
by: Abhishek | last post by:
why do I see that in most C programs, pointers in functions are accepted as: int func(int i,(void *)p) where p is a pointer or an address which is passed from the place where it is called. what...
27
by: Erik de Castro Lopo | last post by:
Hi all, The GNU C compiler allows a void pointer to be incremented and the behaviour is equivalent to incrementing a char pointer. Is this legal C99 or is this a GNU C extention? Thanks in...
24
by: Rob Hoelz | last post by:
Hello everyone, I'm working on a hashtable-based dictionary implementation in C, and it uses void pointers for data storage, naturally. However, since one of the data types I will be using it...
6
by: jacek.dziedzic | last post by:
Hello! I have some legacy C code which expects a pointer to a function to be evaluated at one point. Because of the pointer-to-function vs. pointer-to-member incompatibility, this needs to be a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.