winmd 4.0.1 copy "winmd: ^4.0.1" to clipboard
winmd: ^4.0.1 copied to clipboard

A Dart package for working with Windows Metadata (.winmd) files.

A package that provides a Dart language abstraction over Windows Metadata (WinMD) files, making it possible to load them and build Dart FFI interop libraries from the results.

It can be used to query Windows developer APIs, encompassing both unmanaged APIs like Win32 or COM, as well as modern APIs like Windows Runtime (WinRT) that include their own metadata.

Part of the Dart | Windows suite of Windows packages.

ci Package: winmd Publisher: win32.pub Language: Dart License: BSD-3-Clause codecov

Architecture #

Architecture diagram

Usage #

Windows Runtime (WinRT) #

Load the MediaPlayer class and print out its methods.

import 'package:winmd/winmd.dart';

void main() async {
  // Load the WinRT metadata
  final scope = await MetadataStore.loadWinRTMetadata();

  // A Windows Runtime class
  const typeToGenerate = 'Windows.Media.Playback.MediaPlayer';

  // Find the TypeDef for this class
  final typeDef = scope.findTypeDef(typeToGenerate)!;

  // Create a Dart projection
  print('$typeToGenerate contains the following methods:');

  for (final method in typeDef.methods) {
    print('  ${method.name}');
  }
}

Win32 #

Load all the methods from the GDI namespace and print out some metadata.

import 'package:winmd/winmd.dart';

void main() async {
  // Load the Win32 metadata
  final scope = await MetadataStore.loadWin32Metadata();

  // Find a namespace
  final namespace =
      scope.findTypeDef('Windows.Win32.UI.WindowsAndMessaging.Apis')!;

  // Sort the functions alphabetically
  final sortedMethods = namespace.methods
    ..sort((a, b) => a.name.compareTo(b.name));

  // Find a specific function
  const funcName = 'MessageBoxW';
  final method = sortedMethods.firstWhere((m) => m.name == funcName);

  // Print out some information about it
  print('Win32 function $funcName [token #${method.token}]');

  // Retrieve its parameters and project them into Dart FFI types
  final params = method.parameters
      .map((param) =>
          '${param.typeIdentifier.name.split('.').last} ${param.name}')
      .join(', ');
  print('The parameters are:\n  $params');

  final returnType = method.returnType.typeIdentifier.name.split('.').last;
  print('It returns type: $returnType.');
}

Packages built on winmd #

  • win32: provides Dart FFI bindings to the Win32 API, allowing you to call unmanaged Windows APIs using Dart types.
  • windows_*: provides idiomatic Dart projection of the modern Windows Runtime (WinRT) APIs.

Feature requests and bugs #

Please file feature requests and bugs at the issue tracker.

9
likes
0
pub points
53%
popularity

Publisher

verified publisherhalildurmus.dev

A Dart package for working with Windows Metadata (.winmd) files.

Homepage
Repository (GitHub)
View/report issues

Topics

#winmd #windows #metadata

License

unknown (license)

Dependencies

archive, ffi, nuget, win32, win32_registry

More

Packages that depend on winmd