![]()
This project contains various .NET assemblies that contain P/Invoke functions, interfaces, enums and structures from Windows libraries. Each assembly is associated with one or a few tightly related libraries. For example, Shlwapi.dll has all the exported functions from shlwapi.lib; Kernel32.dll has all for both kernel32.lib and kernelbase.lib.
All assemblies are available via NuGet and provide builds against .NET 4.8, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, .NET Standard 2.0 & 2.1, Core 3.1 and support SourceLink. Extensions are available for WinForms, WPF, and UWP projects. If you need support for other .NET versions, look to versions 3.3.15 and earlier.
This project releases new versions every few weeks after sufficient testing. New releases are cataloged, along with release notes, in the Releases section and all NuGet packages are published to nuget.org. Each GitHub commit triggers a GitHub Actions build. The status of that build is in the header of this page. The NuGet packages from those pre-release builds are available for test purposes on MyGet's project NuGet source at https://www.myget.org/feed/Packages/vanara. There are details at that site for adding it as a NuGet Source.
-OR-
var bret = Vanara.PInvoke.Kernel32.GetComputerName(sb, ref sbSz);using static Vanara.PInvoke.Kernel32;
var bret = GetComputerName(sb, ref sbSz);
Vanara.PInvoke.Gdi32.dll hosts all functions and supporting enumerations, constants and structures that are exported from gdi32.dll in the system directory.)Vanara.Core or Vanara.PInvoke.Shared.
HIWORD and the structure SIZE are both in Vanara.PInvoke.Shared and classes to simplify interop calls and native memory management are in Vanara.Core.)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.)IDisposable.SafeHandle derivatives named after the Windows API handle. If those handles require a call to a function to release/close/destroy, a derived SafeHANDLE exists that performs that function on disposal.
HTOKEN is defined. SafeHTOKEN builds upon that handle with an automated release calling CloseHandle.Vanara.PInvoke.in statement which will pass the structure by reference without requiring the ref keyword.
BOOL MapDialogRect(HWND hDlg, LPRECT lpRect)bool MapDialogRect(HWND hDlg, in RECT lpRect);Vanara and then followed by a logical name for the functionality. Today, those are Core, Security, SystemServices, Windows.Forms and Windows.Shell.| Assembly | NuGet Link | Description |
|---|---|---|
| Vanara.Core | This library includes shared methods, structures and constants for use throughout the Vanara assemblies. Think of it as windows.h with some useful extensions. It includes:
| |
| Vanara.BITS | Complete .NET coverage of Windows BITS (Background Intelligent Transfer Service) functionality. Provides access to all library functions through Windows 11 and gracefully fails when new features are not available on older OS versions. | |
| Vanara.DirectoryServices | Wrapper classes around Win32 ADs methods and interfaces to provide simplified and object-oriented access to Active Directory and other directory service calls. | |
| Vanara.Management | Extensions and helper classes for System.Management. | |
| Vanara.Net | Abstracted classes around Win32 networking functions to provide simplified and object-oriented access to key networking capabilities like DNS, DHCP, filtering, access, and discovery. | |
| Vanara.PInvoke.DirectX | PInvoke API (methods, interfaces, structures and constants) imported from DirectX. | |
| Vanara.PInvoke.DirectXMath | PInvoke API (methods, structures and constants) imported from Windows DirectX Math. | |
| Vanara.PInvoke.SpeechApi | PInvoke API (methods, structures and constants) imported from Windows Speech API. | |
| Vanara.PInvoke.SpellCheckingApi | PInvoke API (methods, structures and constants) imported from Windows Spell Checking API. | |
| Vanara.Security | Classes for security related items derived from the Vanara PInvoke libraries. Includes extension methods for Active Directory and access control classes, methods for working with accounts, UAC, privileges, system access, impersonation and SIDs, and a full LSA wrapper. | |
| Vanara.SystemServices | Classes for system related items derived from the Vanara PInvoke libraries. Includes extensions for Process (privileges and elavation), FileInfo (compression info), Shared Network Drives and Devices, and ServiceController (SetStartType) that pull extended information through native API calls. | |
| Vanara.VirtualDisk | .NET classes to manage Windows Virtual Storage (VHD and VHDX) using P/Invoke functions from VirtDisk.dll. | |
| Vanara.Windows.Extensions | Extension methods and conversions from Vanara P/Invoke types and methods to Windows Forms types and methods. | |
| 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.Windows.Shell.Common | Common classes for Windows Shell items derived from the Vanara PInvoke libraries. Includes shell items, files, icons, links, and taskbar lists. | |
| Vanara.Windows.Shell | Classes for Windows Shell items derived from the Vanara PInvoke libraries. Includes shell items, files, icons, links, and taskbar lists. | |
| Vanara.WindowsUpdate | Wrapper classes around the Windows Update API to simplify and ensure proper use. | |
| Vanara.WinUI.Extensions | Extension methods and conversions from Vanara P/Invoke types and methods to UWP and WinUI types and methods. | |
| Vanara.WPF.Extensions | Extension methods and conversions from Vanara P/Invoke types and methods to WPF types and methods. |
There are numerous examples in the UnitTest folder and in the WinClassicSamplesCS project that recreates the Windows Samples in C# using Vanara.
C#
99.4%
![]()
This project contains various .NET assemblies that contain P/Invoke functions, interfaces, enums and structures from Windows libraries. Each assembly is associated with one or a few tightly related libraries. For example, Shlwapi.dll has all the exported functions from shlwapi.lib; Kernel32.dll has all for both kernel32.lib and kernelbase.lib.
All assemblies are available via NuGet and provide builds against .NET 4.8, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, .NET Standard 2.0 & 2.1, Core 3.1 and support SourceLink. Extensions are available for WinForms, WPF, and UWP projects. If you need support for other .NET versions, look to versions 3.3.15 and earlier.
This project releases new versions every few weeks after sufficient testing. New releases are cataloged, along with release notes, in the Releases section and all NuGet packages are published to nuget.org. Each GitHub commit triggers a GitHub Actions build. The status of that build is in the header of this page. The NuGet packages from those pre-release builds are available for test purposes on MyGet's project NuGet source at https://www.myget.org/feed/Packages/vanara. There are details at that site for adding it as a NuGet Source.
-OR-
var bret = Vanara.PInvoke.Kernel32.GetComputerName(sb, ref sbSz);using static Vanara.PInvoke.Kernel32;
var bret = GetComputerName(sb, ref sbSz);
Vanara.PInvoke.Gdi32.dll hosts all functions and supporting enumerations, constants and structures that are exported from gdi32.dll in the system directory.)Vanara.Core or Vanara.PInvoke.Shared.
HIWORD and the structure SIZE are both in Vanara.PInvoke.Shared and classes to simplify interop calls and native memory management are in Vanara.Core.)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.)IDisposable.SafeHandle derivatives named after the Windows API handle. If those handles require a call to a function to release/close/destroy, a derived SafeHANDLE exists that performs that function on disposal.
HTOKEN is defined. SafeHTOKEN builds upon that handle with an automated release calling CloseHandle.Vanara.PInvoke.in statement which will pass the structure by reference without requiring the ref keyword.
BOOL MapDialogRect(HWND hDlg, LPRECT lpRect)bool MapDialogRect(HWND hDlg, in RECT lpRect);Vanara and then followed by a logical name for the functionality. Today, those are Core, Security, SystemServices, Windows.Forms and Windows.Shell.| Assembly | NuGet Link | Description |
|---|---|---|
| Vanara.Core | This library includes shared methods, structures and constants for use throughout the Vanara assemblies. Think of it as windows.h with some useful extensions. It includes:
| |
| Vanara.BITS | Complete .NET coverage of Windows BITS (Background Intelligent Transfer Service) functionality. Provides access to all library functions through Windows 11 and gracefully fails when new features are not available on older OS versions. | |
| Vanara.DirectoryServices | Wrapper classes around Win32 ADs methods and interfaces to provide simplified and object-oriented access to Active Directory and other directory service calls. | |
| Vanara.Management | Extensions and helper classes for System.Management. | |
| Vanara.Net | Abstracted classes around Win32 networking functions to provide simplified and object-oriented access to key networking capabilities like DNS, DHCP, filtering, access, and discovery. | |
| Vanara.PInvoke.DirectX | PInvoke API (methods, interfaces, structures and constants) imported from DirectX. | |
| Vanara.PInvoke.DirectXMath | PInvoke API (methods, structures and constants) imported from Windows DirectX Math. | |
| Vanara.PInvoke.SpeechApi | PInvoke API (methods, structures and constants) imported from Windows Speech API. | |
| Vanara.PInvoke.SpellCheckingApi | PInvoke API (methods, structures and constants) imported from Windows Spell Checking API. | |
| Vanara.Security | Classes for security related items derived from the Vanara PInvoke libraries. Includes extension methods for Active Directory and access control classes, methods for working with accounts, UAC, privileges, system access, impersonation and SIDs, and a full LSA wrapper. | |
| Vanara.SystemServices | Classes for system related items derived from the Vanara PInvoke libraries. Includes extensions for Process (privileges and elavation), FileInfo (compression info), Shared Network Drives and Devices, and ServiceController (SetStartType) that pull extended information through native API calls. | |
| Vanara.VirtualDisk | .NET classes to manage Windows Virtual Storage (VHD and VHDX) using P/Invoke functions from VirtDisk.dll. | |
| Vanara.Windows.Extensions | Extension methods and conversions from Vanara P/Invoke types and methods to Windows Forms types and methods. | |
| 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.Windows.Shell.Common | Common classes for Windows Shell items derived from the Vanara PInvoke libraries. Includes shell items, files, icons, links, and taskbar lists. | |
| Vanara.Windows.Shell | Classes for Windows Shell items derived from the Vanara PInvoke libraries. Includes shell items, files, icons, links, and taskbar lists. | |
| Vanara.WindowsUpdate | Wrapper classes around the Windows Update API to simplify and ensure proper use. | |
| Vanara.WinUI.Extensions | Extension methods and conversions from Vanara P/Invoke types and methods to UWP and WinUI types and methods. | |
| Vanara.WPF.Extensions | Extension methods and conversions from Vanara P/Invoke types and methods to WPF types and methods. |
There are numerous examples in the UnitTest folder and in the WinClassicSamplesCS project that recreates the Windows Samples in C# using Vanara.
C#
99.4%