Go to file
David Hall 3bbc8909e6 Updated for 1.0.5 build 2017-12-27 17:16:49 -07:00
Core Changed project version to 1.0.5 2017-12-14 21:26:21 -07:00
HelpBuilder Changed project version to 1.0.5 2017-12-14 21:26:21 -07:00
PInvoke Updated for 1.0.5 build 2017-12-27 17:16:49 -07:00
Security Changed project version to 1.0.5 2017-12-14 21:26:21 -07:00
System Minor vd tweaks 2017-12-22 09:47:09 -07:00
UnitTests Minor vd tweaks 2017-12-22 09:47:09 -07:00
WIndows.Forms Finished corrections from changes to UxTheme 2017-12-27 17:16:28 -07:00
Windows.Shell Changed project version to 1.0.5 2017-12-14 21:26:21 -07:00
docs/icons markdown doesn't work in docs so moving to wiki 2017-12-06 17:28:00 -07:00
.gitattributes Add initial files 2017-11-27 10:03:14 -07:00
.gitignore Updated projects to 1.0.4, added release notes, and updated correlation reports. 2017-12-10 18:45:07 -07:00
LICENSE Add initial files 2017-11-27 10:03:14 -07:00
README.md Update README.md 2017-12-13 19:26:12 -07:00
Vanara.sln Added stub project for IpHlpApi.dll 2017-12-24 10:34:16 -07:00

README.md

Vanara

In a number of projects I have needed to use native API calls. Over the years I have collected quite a few of these interop code chunks and I decided to pull them all together into a set of reusable libraries. I have tried to carve up the libraries into small enough chunks that they are easy to identify and consume. The only problem with this is that you can literally end up with over 20 dependencies on some of the higher function libraries (oh well).

I have tried to follow the concepts below in laying out the libraries.

  • All functions that are imported from a single DLL should be placed into a single assembly that is named after the DLL
    • (e.g. The assembly Vanara.PInvoke.Gdi32.dll hosts all functions and supporting enumerations, constants and structures that are exported from gdi32.dll in the system directory.)
  • Any structure or macro or enumeration (no function) that is used by many libraries is put into either Vanara.Core or Vanara.PInvoke.Shared
    • (e.g. The macro HIWORD and the structure SIZE are both in Vanara.PInvoke.Shared and classes to simplfy interop calls and native memory management are in Vanara.Core.)
  • Inside a project, all constructs are contained in a file named after the header file (*.h) in which they are defined in the Windows API
    • (e.g. In the Vanara.PInvoke.Kernel32 project directory, you'll find a FileApi.cs, a WinBase.cs and a WinNT.cs file representing fileapi.h, winbase.h and winnt.h respectively.)
  • Where the direct interpretation of a structure leads to memory leaks or misuse, I have tried to simplify their use
  • Where structures are always passed by reference and where that structure needs to clean up memory allocations, I have changed the structure to class implementing IDisposable.
  • Wherever possible, all handles have been turned into SafeHandle derivatives.
  • Wherever possible, all functions that allocate memory that is to be freed by the caller use a safe memory handle.
  • All PInvoke calls are in assemblies prefixed by Vanara.PInvoke
  • If there are classes or extensions that make use of the PInvoke calls, they are in wrapper assemblies prefixed by Vanara and then followed by a logical name for the functionality. Today, those are Core, Security, SystemServices and UI.

Installation

This project's assemblies are available via NuGet.

Link Assembly Description Dependencies
NuGet Vanara.Core Shared methods, structures and constants for use throughout the Vanara assemblies. Think of it as windows.h with some useful extensions. None
NuGet Vanara.PInvoke.Shared Shared methods, structures and constants for use throughout the Vanara.PInvoke assemblies Vanara.Core
NuGet Vanara.PInvoke.AclUI Methods, structures and constants imported from AclUI.dll Vanara.PInvoke.Security
NuGet Vanara.PInvoke.ComCtl32 Methods, structures and constants imported from ComCtl32.dll Vanara.PInvoke.User32
NuGet Vanara.PInvoke.Crypt32 Methods, structures and constants imported from Crypt32.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.CredUI Methods, structures and constants imported from CredUI.dll Vanara.PInvoke.Security
NuGet Vanara.PInvoke.DwmApi Methods, structures and constants imported from DwmApi.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.Gdi32 Methods, structures and constants imported from Gdi32.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.Kernel32 Methods, structures and constants imported from Kernel32.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.Mpr Methods, structures and constants imported from Mpr.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.NetApi32 Methods, structures and constants imported from NetApi32.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.NetListMgr Methods, structures and constants imported from NetListMgr.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.NTDSApi Methods, structures and constants imported from NTDSApi.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.Ole Methods, structures and constants imported from Ole32.dll, OleAut32 and PropSys.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.Security Methods, structures and constants imported from AdvApi32.dll, Authz.dll and Secur32.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.Shell32 Methods, structures and constants imported from Shell32.dll Vanara.PInvoke.ComCtl32, Vanara.PInvoke.Ole, Vanara.PInvoke.Security
NuGet Vanara.PInvoke.ShlwApi Methods, structures and constants imported from ShlwApi.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.TaskSchd Methods, structures and constants imported from TaskSchd.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.User32 Methods, structures and constants imported from User32.dll Vanara.PInvoke.Kernel32
NuGet Vanara.PInvoke.User32.Gdi Methods, structures and constants imported from User32.dll that have GDI references Vanara.PInvoke.Gdi32, Vanara.PInvoke.Kernel32
NuGet Vanara.PInvoke.UxTheme Methods, structures and constants imported from UxTheme.dll Vanara.PInvoke.Gdi32
NuGet Vanara.PInvoke.VirtDisk Methods, structures and constants imported from VirtDisk.dll Vanara.PInvoke.Shared
NuGet Vanara.PInvoke.WinINet Methods, structures and constants imported from WinINet.dll Vanara.PInvoke.Shared
NuGet Vanara.Security Wrapper classes for security related items in the PInvoke libraries Vanara.PInvoke.NTDSApi, Vanara.PInvoke.Security
NuGet Vanara.SystemServices Wrapper classes for system related items in the PInvoke libraries Vanara.PInvoke.Kernel32, Vanara.PInvoke.NetListMgr, Vanara.PInvoke.VirtDisk
NuGet Vanara.Windows.Forms Classes for user interface related items derived from the Vanara PInvoke libraries. Includes extensions for almost all common controls to give post Vista capabilities, WinForms controls (panel, commandlink, enhanced combo boxes, IPAddress, split button, trackbar and themed controls), shutdown/restart/lock control, buffered painting, resource files, access control editor, simplifed designer framework for Windows.Forms. Vanara.PInvoke.AclUI, Vanara.PInvoke.CredUI, Vanara.PInvoke.ComCtl32, Vanara.PInvoke.DwmApi, Vanara.PInvoke.UxTheme
NuGet Vanara.Windows.Shell Classes for Windows Shell items derived from the Vanara PInvoke libraries. Includes shell items, files, icons, links, and taskbar lists. Vanara.PInvoke.Shell32

Sample Code

There are numerous examples in the UnitTest folder.