dllimport_gen 1.2.2 copy "dllimport_gen: ^1.2.2" to clipboard
dllimport_gen: ^1.2.2 copied to clipboard

outdated

A code generation tool that aims to quickly generate dart code from the windows api documentation emulating the DllImport notation in C#.

A code generation tool that aims to quickly generate dart code from the windows api documentation emulating the DllImport notation in C#.

Example:

import 'package:dllimport_gen/dll_import.dart';

import 'example.ffi.g.dart';

@DllImport('user32.dll')
abstract class User32 {
  /// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setcursorpos
  BOOL SetCursorPos(int X, int Y);
}

@DllImport('kernel32.dll')
abstract class Kernel32 {
  /// https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror
  DWORD GetLastError();
}

void main() {
  var user32 = FFIUser32();
  var kernel = FFIKernel32();
  var success = user32.SetCursorPos(0, 0) != 0;
  if (!success) {
    print('Failed: ${kernel.GetLastError()}');
  }
}

Run the code generation: pub run build_runner build

See example/


Use @Import('<library>') to import a custom library in the generated file, if for example you're using your custom structs.

6
likes
40
pub points
0%
popularity

Publisher

verified publisherhexah.net

A code generation tool that aims to quickly generate dart code from the windows api documentation emulating the DllImport notation in C#.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

analyzer, build, source_gen

More

Packages that depend on dllimport_gen