windart 0.1.1
windart: ^0.1.1 copied to clipboard
Windows API (Win32) bindings for Dart using FFI.
πͺ Windart β Windows API bindings for Dart #
Windart is a Windows API (Win32) binding library for Dart, powered by dart:ffi
.
It gives you direct access to User32, Kernel32, and Gdi32 functions β without writing C or C++ code.
Think of it as Dartβs gateway to the Win32 API π
β¨ Features #
- Full access to common Windows APIs:
User32.dll
β windows, events, input, message boxesKernel32.dll
β processes, files, console, environmentGdi32.dll
β drawing, bitmaps, pens, brushes, regions
- Typed FFI structs for RECT, MSG, PAINTSTRUCT, POINT, etc.
- Dart-friendly wrappers around C functions
- Constants for window messages, key codes, file access, system metrics and more
- 100% pure Dart β no extra DLLs needed, just Windows itself
π Getting Started #
Add the dependency in your pubspec.yaml
:
dependencies:
windart: any
Then run:
dart pub get
π§ Usage Examples #
MessageBox (User32) #
import 'package:windart/windart.dart';
import 'package:ffi/ffi.dart';
void main() {
User32.messageBoxW(
0,
"Hello from Dart!".toNativeUtf16(),
"Windart Demo".toNativeUtf16(),
MB_OK | MB_ICONINFORMATION,
);
}
Console output (Kernel32) #
import 'package:windart/windart.dart';
import 'package:ffi/ffi.dart';
import 'dart:ffi';
void main() {
Kernel32.allocConsole();
final hConsole = Kernel32.getStdHandle(STD_OUTPUT_HANDLE);
final text = "Hello, Windows console π".toNativeUtf16();
final written = calloc<Uint32>();
Kernel32.writeConsoleW(hConsole, text, text.length, written, nullptr);
calloc.free(text);
calloc.free(written);
}
Drawing a rectangle (Gdi32) #
import 'package:windart/windart.dart';
import 'dart:ffi';
void main() {
final hdc = Gdi32.getDC(0);
final pen = Gdi32.createPen(0, 3, 0x00FF0000); // red
final old = Gdi32.selectObject(hdc, pen);
Gdi32.rectangle(hdc, 100, 100, 400, 300);
Gdi32.selectObject(hdc, old);
Gdi32.deleteObject(pen);
Gdi32.releaseDC(0, hdc);
}
π Documentation #
β‘ Roadmap #
- β More APIs:
Advapi32
,Shell32
,Comctl32
- β Higher-level Dart helpers (e.g. GUI widgets, GDI helpers)
β€οΈ Contributing #
Contributions are welcome!
If youβd like to add bindings or improve wrappers, feel free to open a PR or file an issue.
π License #
MIT License β see LICENSE
β οΈ Disclaimer #
This package provides low-level access to Windows internals.
β‘ Be careful: calling APIs with invalid arguments can crash your app.