Click here to Skip to main content
15,875,646 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
I came across this question while studying extern functions.
Which of the following statements about using external functions from unmanaged DLLs are true?
1 - External functions which require a structure to be passed as a parameter cannot be called.
2 - External functions which require a callback function to be passed as a parameter cannot be called.

Do you know the answer please?
Thanks
Posted

1 solution

1 is definitely not true. You can define a structure in managed code and call the extern method[^].

2 is possible in .Net 2.0 but not in 1.1.
.Net 2.0 contains a UnmanagedFunctionPointerAttribute attribute which allows us to pass a delegate to unmanaged code[^].

So basically, AFAIK, 2 would be the right answer for .Net 1.1.
But for .Net 2.0 and beyond, both would be incorrect.

Good question. Had me thinking (and reading) a while.
 
Share this answer
 
v4
Comments
Prerak Patel 24-Aug-11 4:27am    
2 would be the right answer for .Net 1.1
:confused: Needs correction. BTW 5
Abhinav S 24-Aug-11 4:31am    
Thanks for the 5.
What i mean is if this is a question and the OP needs to choose between 1 and 2, then he needs to pick 2 for .Net 1.1.
However, this question does not hold good for .Net 2.0.
Manfred Rudolf Bihy 24-Aug-11 4:42am    
Thanks for the information! 5+
Abhinav S 24-Aug-11 4:43am    
Thank you Manfred.
dan!sh 24-Aug-11 4:44am    
Nice.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900