Click here to Skip to main content
16,018,418 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm a NET newby.
Does anyone understand what happens behind the scenes when using PInvoke in NET?I'm curious as to how the CLR finds the win32 function and how it consumes it.What I'm asking is, does it go to the WIN32 folder and copy the function (or reflect over it) and then use it?What if I'm using win95 or LINUX, does it check the OS type?

[DllImport("user32.dll")]
private static extern int MessageBox( int i,string text, string caption, uint type);

Thanks in advance
Johan
Posted
Comments
Toli Cuturicu 22-Oct-10 14:21pm    
What will you do with the answer? How will you use it?

1 solution

The CLR knows how to specially handle external calls. In this case the external method is invoked the standard way - which is by using LoadLibrary/GetProcAddress. Of course there are details like the plumbing code required to marshal managed types to native types before the call, and then to convert back after the call.
 
Share this answer
 
v2

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