-
Notifications
You must be signed in to change notification settings - Fork 196
Version 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.
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:
-
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
-
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
-
English named safe handles have been renamed to Safe + the name of the Windows API handle
a. E.g. SafeTokenHandle is now SafeHTOKEN
-
All instances of HandleRef have been replaced with the appropriate handle type
a.
SendMessage(HandleRef hwnd, ....)
has been changed toSendMessage(HWND hwnd, ...)
-
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 aToBitmap()
method to convert the handle to aSystem.Drawing.Bitmap
instance.