dart_windows_service_support 0.0.5 copy "dart_windows_service_support: ^0.0.5" to clipboard
dart_windows_service_support: ^0.0.5 copied to clipboard

Support running dart as a Windows service

Dart Windows Service Support 🚀 #

dart_windows_service_support use dart:ffi access dll api

need WindowsServiceDLL.dll support download file for https://github.com/au-top/dart_windows_service/releases or clone git repository make project

Example #

example global var

final dllPath = normalize(join(dirname(Platform.script.toFilePath()), "../../../dll/WindowsServiceDLL64.dll"));
const serviceName = "dart_test_service";

DartConnectServiceDLL.dartInstallService install service

void main(List<String> args) {
  final dartConnectServiceDLL = DartConnectServiceDLL(dllPath);
  final servicePath = join(Directory.current.path, "service.exe");

  dartConnectServiceDLL.dartInstallService(
    serviceName.toNativeUtf16().cast<Uint16>(),
    serviceName.toNativeUtf16().cast<Uint16>(),
    "this is a dart test service".toNativeUtf16().cast<Uint16>(),
    "".toNativeUtf16().cast<Uint16>(),
    0x2,
    "".toNativeUtf16().cast<Uint16>(),
    Pointer.fromAddress(0),
    Pointer.fromAddress(0),

    /// path
    servicePath.toNativeUtf16().cast<Uint16>(),
    1,
    1,
    Pointer.fromAddress(0),
    1,
  );
}

DartConnectServiceDLL.dartConnectService connect service


void main(List<String> args) async {
  final dartConnectServiceDLL = DartConnectServiceDLL(dllPath);
  await Isolate.spawn(run, 'message');
  dartConnectServiceDLL.dartConnectService(serviceName.toNativeUtf16().cast<Uint16>());
}

void run(String message) {
  Timer.periodic(Duration(seconds: 1), (timer) async {
    final f = File("d:/a.txt");
    await f.create();
    await f.writeAsString("${await f.readAsString()}1");
  });
}

DartConnectServiceDLL.dartUninstallService uninstall service

void main(List<String> args) {
  final dartConnectServiceDLL = DartConnectServiceDLL(dllPath);
  dartConnectServiceDLL.dartUninstallService(serviceName.toNativeUtf16().cast<Uint16>());
}

See dart_windows_service_support/example

16
likes
130
points
53
downloads

Publisher

verified publisherautopc.top

Weekly Downloads

Support running dart as a Windows service

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

ffi, path

More

Packages that depend on dart_windows_service_support