Click here to Skip to main content
Click here to Skip to main content

Creating delegate from a function pointer

By , 26 Jun 2011
 
//Assume you have managed to somehow pass a function pointer from C++ as Cplussplusfunctionptr to C#. In my case I was lucky, becoz I had managed C++ as a mid layer to convert void* to IntPtr;

IntPtr func = Cplussplusfunctionptr;
 
GuiFactoryOnNotify delegateOnNotify = (GuiFactoryOnNotify)Marshal.GetDelegateForFunctionPointer
                (func, typeof(GuiFactoryOnNotify)); 
 
 
Thanks to cory nelson in stack overflow for the original tip.

License

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

About the Author

Mukit, Ataul
Chief Technology Officer Rational Technologies
Bangladesh Bangladesh
Member
You don't learn patterns, you just code it.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionCalling Service written in C, from C# PinmemberMuneeb R. Baig4 Jul '11 - 11:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 27 Jun 2011
Article Copyright 2011 by Mukit, Ataul
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid