| Crates.io | winservice |
| lib.rs | winservice |
| version | 0.1.1 |
| created_at | 2016-02-26 20:06:08.971006+00 |
| updated_at | 2016-10-02 21:50:19.473142+00 |
| description | Run a Windows system service without hassle. |
| homepage | https://github.com/fischmax/winservice |
| repository | https://github.com/fischmax/winservice |
| max_upload_size | |
| id | 4298 |
| size | 22,610 |
A very small Rust library to easily set up and run a Windows system service.
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 }