2024-09-03 22:46:04 +00:00
|
|
|
#![windows_subsystem = "windows"]
|
|
|
|
|
2024-09-09 20:49:49 +00:00
|
|
|
use std::{ffi::OsStr, os::windows::ffi::OsStrExt};
|
|
|
|
|
2024-09-03 22:46:04 +00:00
|
|
|
use tray::TrayApp;
|
2024-08-27 18:08:03 +00:00
|
|
|
|
|
|
|
mod controller;
|
|
|
|
mod devices;
|
|
|
|
mod manager;
|
2024-09-03 22:46:04 +00:00
|
|
|
mod tray;
|
2024-08-27 18:08:03 +00:00
|
|
|
|
|
|
|
fn main() {
|
2024-09-05 22:55:10 +00:00
|
|
|
unsafe {
|
|
|
|
// Allocate new console for the process
|
2024-09-09 20:49:49 +00:00
|
|
|
winapi::um::consoleapi::AllocConsole();
|
|
|
|
|
|
|
|
let title: Vec<u16> = OsStr::new("Razer Battery Report Debug Console")
|
|
|
|
.encode_wide()
|
|
|
|
.chain(std::iter::once(0))
|
|
|
|
.collect();
|
|
|
|
winapi::um::wincon::SetConsoleTitleW(title.as_ptr());
|
|
|
|
|
|
|
|
let hwnd = winapi::um::wincon::GetConsoleWindow();
|
|
|
|
|
|
|
|
// Disable close command in the sys.menu of the new console, otherwise the whole process will quit: https://stackoverflow.com/a/12015131/126995
|
|
|
|
if !hwnd.is_null() {
|
|
|
|
let hmenu = winapi::um::winuser::GetSystemMenu(hwnd, 0);
|
|
|
|
if !hmenu.is_null() {
|
|
|
|
winapi::um::winuser::DeleteMenu(
|
|
|
|
hmenu,
|
|
|
|
winapi::um::winuser::SC_CLOSE as u32,
|
|
|
|
winapi::um::winuser::MF_BYCOMMAND,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2024-09-05 22:55:10 +00:00
|
|
|
|
|
|
|
// Hide the console window
|
2024-09-09 20:49:49 +00:00
|
|
|
if !hwnd.is_null() {
|
|
|
|
winapi::um::winuser::ShowWindow(hwnd, winapi::um::winuser::SW_HIDE);
|
|
|
|
}
|
2024-09-05 22:55:10 +00:00
|
|
|
}
|
|
|
|
|
2024-08-27 18:08:03 +00:00
|
|
|
std::env::set_var("RUST_LOG", "trace");
|
|
|
|
pretty_env_logger::init();
|
2024-09-03 22:46:04 +00:00
|
|
|
let checker = TrayApp::new();
|
2024-08-27 18:08:03 +00:00
|
|
|
checker.run();
|
|
|
|
}
|