hwndloop/
util.rs

1use winapi::shared::minwindef::{ATOM, HINSTANCE};
2use winapi::um::winnt::LPWSTR;
3
4extern "C" {
5  pub static __ImageBase: u8;
6}
7
8pub fn get_module_handle() -> HINSTANCE {
9  unsafe { &__ImageBase as *const u8 as HINSTANCE }
10}
11
12pub fn atom_to_lpwstr(atom: ATOM) -> LPWSTR {
13  // The atom must be in the low-order word of lpClassName; the high-order word must be zero.
14  atom as usize as LPWSTR
15}
16
17pub fn to_utf16(s: &str) -> Vec<u16> {
18  s.encode_utf16().chain(Some(0).into_iter()).collect()
19}