Use API functions in C#

  • Thread starter Thread starter Le, Thanh-Nhan
  • Start date Start date
L

Le, Thanh-Nhan

Hi,
How can I use API functions in C#.
Is there in VS .Net any simple Way to use, declare an API Function?

Thanks
Nhan
 
Le said:
Hi,
How can I use API functions in C#.
Is there in VS .Net any simple Way to use, declare an API Function?

Thanks
Nhan
Accessing unmanaged code from the .net can be done either through COM
interop or using p/invoke. P/invoke is what you need when dealing with
windows API. It basically involves a special declarations in your c#
code where you will specify a function name, library where it comes
through, and its calling signiture in c#. The hardest part is to get the
signitures and various struct layout declarations right so that the
calls from c# are marshalled right to unmanaged world. The most
excellent source for all this is pinvoke wiki:

http://www.pinvoke.net/

I love this site and you can just find the windows API function that you
want to use and they will give you a c# decl for it. Not all of the
functions have examples, but once you get better, you can post examples
there too because the site is wiki.

laimis
 
Back
Top