winservice

A very small Rust library to easily set up and run a Windows system service.

Documentation

Example Usage

Cargo.toml:

toml [dependencies] winservice = "0.1.0"

main.rs:

```rust

![no_main]

![feature(link_args)]

![link_args = "-Wl,--subsystem,windows"]

use std::os::raw::{cchar, cint, c_void}; use std::sync::mpsc::Receiver;

[macro_use]

extern crate winservice;

[allow(nonsnakecase)]

[no_mangle]

pub extern "system" fn WinMain(hInstance : *const cvoid, hPrevInstance : *const cvoid, lpCmdLine : *const cchar, nCmdShow : cint) -> cint { Service!("myService", servicemain); 0 }

fn servicemain(args : Vec, end : Receiver<()>) -> u32 { loop { // Do some work if let Ok() = end.try_recv() { break; } } 0 } ```

Documentation