Managed Windows API

A collection of .NET components that wrap PInvoke calls to access native API by managed code.

What is "Managed Windows API" good for?

The Problem

If you want use Windows functionality in a .NET application which is not covered by the .NET framework (there is no "managed API" available for it), you usually have to use PInvoke, an interface that allows to invoke raw API functions from C# and VB.NET.

However, this is quite cumbersome. does a great job in helping you to get the correct PInvoke declaration, but still you have to do lots of error-checking and ensure that you did not forget to handle all the corner cases. When accessing PInvoke declarations directly, this may lead to low-level code spread all over your apllication.

To avoid that, you usually write your own C# classes or .NET components to wrap all PInvoke stuff and provide the caller with a nice, high-level interface for the low-level API (that uses enums for enumerated values, reports errors by throwing exceptions, etc.)

However, if every developer does this for every API he uses, lots of time and energy is wasted for reinventing the wheel.

The solution

"Managed Windows API" is a collection of C# components that wrap Windows API functionality. It contains those features the author needed for his C# development, but if you have components yourself you want to share, please submit them so that this project can grow.

Are there example programs available?

Yes and no. You might have a look at the Managed Windows API Tools. Started as a collection of ManagedWinapi samples, the Managed Winapi tools evolved into a toolbox of lots of small but useful tools that solve their specific task well. They can still be used as reference for how to use ManagedWinapi, but their functionality may make it hard to find the relevant code parts quickly.

Where can I download those components?

Binary download (including HTML-help documentation) (Version 0.3, 391 KB)

Source download (Version 0.3, 578 KB)

Tools (Version 0.3, 205 KB)

What components are included?

See the HTML documentation (generated by Sandcastle Help File Builder)

What is the license of these components?

These components are licensed by the GNU Lesser General Public License (LGPL) which allows to use these componenst both in open-source and commercial projects. The full license text (for your lawyer) is available at the GNU website, a short summary can be found on the Creative Commons website.

So, may I include these components into commercial, closed source, software?

Yes, you may use the binary download (i. e. the .dll) include into any piece of software, as long as it remains unmodified. You must as well allow the end user to replace this .dll (i. e. you may not include it into your .exe file) but usually this is the case anyway.

However, if you want to modify those files (and sending these modifications to the project for inclusion is no option for you), you will have to give these modifications (i. e. all files you need to build your modified .dll) to everyone who gets your program (or include a written offer for that). So usually, sending these modifications to the project is much less work - and helps much more people.

And if my program is open source (GPL'ed)?

If your program is GPL'ed, you will have to include your source code anyway. In this case, you may as well link these components into your assembly statically (for example by copying the .cs files into your project folder).


You can get the latest source code (and check in your additions if you are a developer) from subversion.

Anonymous access: Use
svn co mwinapi
to check out the latest version. You can also use GUI programs like TortoiseSVN (Explorer plugin) or AnkhSVN (Visual Studio plugin).

Developer access: Contact me so that I can add you to this project. You will need a account for this. Or submit your changes by e-mail; then I will commit them.

You can also browse the repository.

Contact me

If you want to contact me or want to submit your own code to this project, please contact me at Have fun! Logo