winservice 0.1.1

Run a Windows system service without hassle.
Documentation
  • Coverage
  • 100%
    1 out of 1 items documented0 out of 0 items with examples
  • Size
  • Source code size: 22.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.15 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Documentation
  • yasammez/winservice
    10 3 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • yasammez

winservice

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

Documentation

Example Usage

Cargo.toml:

[dependencies]
winservice = "0.1.1"

main.rs:

#![no_main]
#![feature(link_args)]
#![link_args = "-Wl,--subsystem,windows"]

use std::os::raw::{c_char, c_int, c_void};
use std::sync::mpsc::Receiver;

#[macro_use]
extern crate winservice;

#[allow(non_snake_case)]
#[no_mangle]
pub extern "system" fn WinMain(hInstance : *const c_void, hPrevInstance : *const c_void,
    lpCmdLine : *const c_char, nCmdShow : c_int) -> c_int
{
    Service!("myService", service_main)
}

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