win32 6.0.0 copy "win32: ^6.0.0" to clipboard
win32: ^6.0.0 copied to clipboard

Call common Windows APIs directly from Dart using FFI.

win32 README banner

🎯 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()}');
    }
  });
}
MessageBox example screenshot

📝 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:

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.


win32 contributors graph

🎉 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.

933
likes
160
points
4.09M
downloads
screenshot

Publisher

verified publisherhalildurmus.dev

Weekly Downloads

Call common Windows APIs directly from Dart using FFI.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#win32 #windows #ffi

Documentation

Documentation
API reference

Funding

Consider supporting this project:

github.com

License

BSD-3-Clause (license)

Dependencies

code_assets, ffi, ffi_leak_tracker, hooks, logging, meta, native_toolchain_c

More

Packages that depend on win32