Title: Quick tip: Use pinvoke.net to get information about API functions for use in C#
Platform Invocation Services (pinvoke) allows managed .NET code to call unmanaged API functions that are implemented in a DLL. The functions in a DLL are exposed via an Application Programming Interface (API).
The enormous .NET runtime library wraps many API functions in managed code so you don't need to use pinvoke to call them for many everyday tasks. Occasionally, however, you'll stumble across some API function that you want to use and that is not available via managed code.
When that happens, first check again to make sure the function isn't available through managed code. Often you won't find the managed version of an API call until you dig a bit.
If you're pretty sure the function is only available via an API, go to pinvoke.net. This site contains the C# and Visual Basic declarations for thousands of API function calls and the constants and structures you need to use them. It includes examples that can save you a lot of time and trouble trying to figure out how to use the functions on your own.
Use the search box in the upper left corner to find the API function you need to use. On the results page, click the link to the correct entry (often a search finds multiple possible matches) to get more detailed information.
|