🎯 Overview
package:win32 exposes a curated surface of Win32 and
COM (Component Object Model) APIs through Dart FFI, enabling
functionality that is not available through dart:io, Flutter plugins,
or platform channels.
Typical use cases include:
- Flutter apps on Windows Access system settings, hardware devices, registry data, native dialogs, and other OS-level features unavailable through Dart or Flutter itself.
- Platform-specific implementations Write cross-platform packages with a Windows-specific backend.
- Advanced tooling and utilities Build command-line tools or background services that require native file, process, or security APIs.
⚡ Quick Example
The example below shows how to call a native Win32 API directly from Dart:
import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart';
void main() {
using((arena) {
final Win32Result(:value, :error) = MessageBox(
null,
arena.pcwstr('Hello from Dart'),
arena.pcwstr('Dart Win32 MessageBox Demo'),
MB_OK | MB_ICONINFORMATION,
);
switch (value) {
case IDOK:
print('OK pressed');
case 0:
print('MessageBox failed: ${error.toHRESULT()}');
}
});
}
📝 Documentation
Full documentation, conceptual guides, and API references are available at win32.pub/docs.
Start with the Quick Start guide to make your first Win32 API call.
🌟 Examples
This repository includes a wide range of examples demonstrating real-world usage in the examples directory:
- Flutter desktop apps using native Win32 APIs
- System information tools
- Traditional Win32 GUI applications written in Dart
- Games using GDI
- USB and system event monitoring
- COM interop scenarios
Here are some screenshots from examples built with package:win32:
📦 Packages Built on package:win32
Many Dart packages build on top of package:win32 to provide more idiomatic
APIs:
- filepicker_windows — Access to native Windows file dialogs
- win32_clipboard — Access to Windows clipboard
- win32_gamepad — Access to gamepads
- win32_gui — Object-oriented Win32 GUI APIs
- win32_registry — Access to Windows Registry
- win32_runner — Experimental Flutter runner
Find more packages on pub.dev.
🐞 Features and Bugs
package:win32 exposes a subset of the Windows API, with more APIs added
regularly based on user demand.
If you encounter bugs or need additional functionality, please file an issue.
🙏 Contributors
Thank you to everyone who contributes by writing code, reporting issues,
reviewing pull requests, or building packages on top of package:win32.
🎉 Acknowledgements
The original C version of the custom titlebar example is by Dmitriy Kubyshkin and is licensed under the MIT License.
Win32 API documentation comments are licensed by Microsoft under the Creative Commons Attribution 4.0 International Public License.
Libraries
- win32
- Provides direct, strongly-typed access to core Win32 and COM APIs for Windows development.
