2 Version 2.x
David Hall edited this page 2018-09-21 23:23:09 -06:00

Vanara Libraries 2.x

Welcome to the Vanara Libraries and thank you for downloading!

These assemblies span many of the Windows API libraries. Information about the full set of libraries and which API are covered can be found on our project home page.

If you're looking for pure P/Invoke calls, then check out the assemblies labeled Vanara.PInvoke.[DllName]. Each one has many, if not all, the functions, structures, enums and interfaces found in the Windows API header files.

To 1.x Users

First of all, let me apologize to those of you who have been using any of the 1.x versions of Vanara. You will likely curse me when you upgrade to 2.x due to the number of breaking changes introduced. In my defense, it had to happen. In version 2.0, all handles are now typed for your protection. All handles that self dispose are now clearly labeled as 'Safe'. You ask why I didn't chose to do this from the beginning. All I can say is: lack of foresight. As the library grew, I realized I couldn't go on with random IntPtr handles and being too lazy to create typed handles. That is now corrected.

If you attempting to upgrade, here are some suggestions on modifying your code:

  1. All handles have a base H[NAME] class, which does nothing other than hold the handle (IntPtr) and is named identically to the Windows API name.

    a. E.g. HFILE, HTOKEN, HDC

  2. All handles that have finalizers that are called to close the handle on disposal have Safe prepended to the handle name

    a. E.g. SafeHFILE, SafeHTOKEN, SafeHDC

  3. English named safe handles have been renamed to Safe + the name of the Windows API handle

    a. E.g. SafeTokenHandle is now SafeHTOKEN

  4. All instances of HandleRef have been replaced with the appropriate handle type

    a. SendMessage(HandleRef hwnd, ....) has been changed to SendMessage(HWND hwnd, ...)

  5. Where handles can be converted to .NET Framework classes, there is a To[ClassName]() method on the handle class or with an extension method to the handle that will perform that conversion safely (i.e. handles are copied when they will be disposed).

    a. SafeHBITMAP has a ToBitmap() method to convert the handle to a System.Drawing.Bitmap instance.