Skip to content

Instantly share code, notes, and snippets.

@jbevain
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbevain/08f8138f1237715269db to your computer and use it in GitHub Desktop.
Save jbevain/08f8138f1237715269db to your computer and use it in GitHub Desktop.
#![feature(lang_items)]
#![allow(unstable)]
#![allow(non_camel_case_types)]
extern crate libc;
extern crate unicode;
mod w32 {
use libc::types::os::arch::extra::{HANDLE, LPCWSTR};
pub type UINT = u32;
pub type INT = i32;
pub type HWND = HANDLE;
pub type LPCTSTR = LPCWSTR;
#[link(name = "user32")]
extern "stdcall" {
pub fn MessageBoxW(hWnd: HWND, lpText: LPCTSTR, lpCaption: LPCTSTR, uType: UINT) -> INT;
}
}
macro_rules! L(
($e: expr) => ({
((|&: s: &str| -> Vec<u16> {
let mut v: Vec<u16> = s.utf16_units().collect();
v.push(0);
return v;
})($e)).as_ptr()
})
);
fn main() {
unsafe {
w32::MessageBoxW(std::ptr::null_mut(), L!("Yodélilà"), L!("YO YO YO YO"), 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment