TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
lapalmejames
NA
1
0
PInvokes with managed and unmanaged objects
Feb 6 2004 1:53 AM
Dear All, I created a dll with the following: extern "C" _declspec(dllexport) int myFunction(A*){return a->myInt();} class A{ public: int i; int myInt(void){rerturn i;} } I creates a C# client with the folllowing: public class MyClient{ [DllImport("MyDll.dll")] public static extern in myFunction(A a); public static void Main(){ A a = new A(); a.i=5; Console.WriteLine(myFunction(a)); } } [StructureLayout(LayputKind.Sequential)] public class A{ public int i; public int myInt(void){rerturn i;} } This code works.... should I be surpise that I'm able to minic unmanaged classes with managed classes, marshall the managed classes through PInvoke and then let unmanaged code call methods on the managed classes...? Is this code good or should I be avoiding this and only use managed classes to minic unmanaged structures that contain no methods? James
Reply
Answers (
0
)
Excel Interop with older versions of Excel
How to use InternetGetProxyInfo from jsproxy.dll