Windy

Windows strings library

This crate supports AString (ANSI string) and WString (Unicode string).

Features

Example

```rust use windy::*;

[allow(nonsnakecase)]

extern "system" { fn GetEnvironmentVariableA(lpName: *const u8, lpBuffer: *mut u8, nSize: u32) -> u32; fn GetEnvironmentVariableW(lpName: *const u16, lpBuffer: *mut u16, nSize: u32) -> u32; }

fn getenvironmentvariablea() { let name = AString::fromstr("PATH").unwrap(); let mut buf = Vec::withcapacity(0x1000); unsafe { let l = GetEnvironmentVariableA( name.asptr(), buf.asmutptr(), 0x1000); if l == 0 { println!("GetEnvironmentVariableA failed"); return; } buf.setlen(l as usize); let value = AString::newunchecked(buf); println!("value: {}", value.tostringlossy()); } }

fn getenvironmentvariablew() { let name = WString::fromstr("PATH").unwrap(); let mut buf = Vec::withcapacity(0x1000); unsafe { let l = GetEnvironmentVariableW( name.asptr(), buf.asmutptr(), 0x1000); if l == 0 { println!("GetEnvironmentVariableW failed"); return; } buf.setlen(l as usize); let value = WString::newunchecked(buf); println!("value: {}", value.tostringlossy()); } }

fn main() { println!("get_environment_variable_a"); getenvironmentvariablea(); println!("*getenvironmentvariablew*"); getenvironmentvariable_w(); } ```

License

This software is released under the MIT or Apache-2.0 License, see LICENSE-MIT or LICENSE-APACHE.