Chapter.Net.WinAPI
1.1.0
See the version list below for details.
dotnet add package Chapter.Net.WinAPI --version 1.1.0
NuGet\Install-Package Chapter.Net.WinAPI -Version 1.1.0
<PackageReference Include="Chapter.Net.WinAPI" Version="1.1.0" />
paket add Chapter.Net.WinAPI --version 1.1.0
#r "nuget: Chapter.Net.WinAPI, 1.1.0"
// Install Chapter.Net.WinAPI as a Cake Addin #addin nuget:?package=Chapter.Net.WinAPI&version=1.1.0 // Install Chapter.Net.WinAPI as a Cake Tool #tool nuget:?package=Chapter.Net.WinAPI&version=1.1.0
<img src="https://raw.githubusercontent.com/dwndland/Chapter.Net.WinAPI/master/Icon.png" alt="logo" width="64"/>
Chapter.Net.WinAPI Library
Overview
During development of the Chapter libraries, it happens easily from time to time that native WinAPI calls must be made. Thats the reason why this Chapter.Net.WinAPI library exists. Note: The Chapter.Net.WinAPI is far from complete, it contains only methods needed for any other Chapter.Net libraries and it will continue grow that way only. But of course, it it contains anything you may need in your application. Feel free to use it.
Features
- Dwmapi: Access to the WinAPI methods within the "dwmapi.dll"
- Kernel32: Access to WinAPI methods within the "kernel32.dll".
- Shell32: Access to WinAPI methods within the "shell32.dll".
- User32: Access to WinAPI methods within the "user32.dll".
- Data: Values and structures to use within any of those above. Like WM (WindowMessages), WH (WindowHandle) and many more.
Getting Started
Installation:
- Install the Chapter.Net.WinAPI library via NuGet Package Manager:
dotnet add package Chapter.Net.WinAPI
Usage:
- Direct access the objects like
User32.ShowWindow(windowHandle, WindowShowStyle.Restore);
- Or a wrapper
public class Demo { public Demo(IUser32 user32) { _user32 = user32; } public void RestoreWindow(Window window) { var windowHandle = ((HwndSource)PresentationSource.FromVisual(window))!.Handle; _user32.ShowWindow(windowHandle, WindowShowStyle.Restore); } }
Example
- Target
public class Demo { public Demo(IUser32 user32) { _user32 = user32; } public void RestoreWindow(Window window) { var windowHandle = ((HwndSource)PresentationSource.FromVisual(window))!.Handle; _user32.ShowWindow(windowHandle, WindowShowStyle.Restore); } }
- UnitTest
public class DemoTests { private Demo _target, [Setup] public void Setup() { _user32 = new Mock<IUser32>(); _target = new Demo(_user32.Object); } [Test] public void RestoreWindow_CalledAfterMinimizedFromNormal_RestoresTheWindowBackToNormal() { var window = Utils.OpenDummyWindow(); window.WindowState = WindowState.Normal; window.WindowState = WindowState.Minimized; _target.RestoreWindow(window); _user32.Verify(x => x.ShowWindow(It.IsAny<nint>(), WindowShowStyle.Restore), Times.Once()); Assert.That(window.WindowState, Is.EqualTo(WindowState.Normal)); } [Test] public void RestoreWindow_CalledAfterMinimizedFromNormal_RestoresTheWindowBackToMaximized() { var window = Utils.OpenDummyWindow(); window.WindowState = WindowState.Maximized; window.WindowState = WindowState.Minimized; _target.RestoreWindow(window); _user32.Verify(x => x.ShowWindow(It.IsAny<nint>(), WindowShowStyle.Restore), Times.Once()); Assert.That(window.WindowState, Is.EqualTo(WindowState.Maximized)); } }
Links
License
Copyright (c) David Wendland. All rights reserved. Licensed under the MIT License. See LICENSE file in the project root for full license information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Chapter.Net.WinAPI:
Package | Downloads |
---|---|
Chapter.Net.Processes
Chapter.Net.Processes brings access and handlers to local processes and assemblies. |
|
Chapter.Net.WPF
Brings additional behavior and features to WPF in general. |
GitHub repositories
This package is not used by any popular GitHub repositories.