Skip to content

Commit 256538e

Browse files
committed
readme
1 parent 5f753aa commit 256538e

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

readme.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,24 @@ This will allow Cargo to download, build, and cache Windows support as a package
2626
fn main() {
2727
windows::build!(
2828
windows::data::xml::dom::*
29-
windows::ui::*
29+
windows::win32::system_services::{CreateEventW, SetEvent, WaitForSingleObject}
30+
windows::win32::windows_programming::CloseHandle
3031
);
3132
}
3233
```
3334

34-
Finally, make use of any Windows APIs as needed. For example, here is an example of using the `XmlDocument` class to parse an XML document.
35+
Finally, make use of any Windows APIs as needed.
3536

3637
```rust
3738
mod bindings {
3839
::windows::include_bindings!();
3940
}
4041

41-
use bindings::windows::data::xml::dom::XmlDocument;
42+
use bindings::{
43+
windows::data::xml::dom::*,
44+
windows::win32::system_services::{CreateEventW, SetEvent, WaitForSingleObject},
45+
windows::win32::windows_programming::CloseHandle,
46+
};
4247

4348
fn main() -> windows::Result<()> {
4449
let doc = XmlDocument::new()?;
@@ -48,6 +53,19 @@ fn main() -> windows::Result<()> {
4853
assert!(root.node_name()? == "html");
4954
assert!(root.inner_text()? == "hello world");
5055

56+
unsafe {
57+
let event = CreateEventW(
58+
std::ptr::null_mut(),
59+
true.into(),
60+
false.into(),
61+
std::ptr::null(),
62+
);
63+
64+
SetEvent(event).ok()?;
65+
WaitForSingleObject(event, 0);
66+
CloseHandle(event).ok()?;
67+
}
68+
5169
Ok(())
5270
}
5371
```

0 commit comments

Comments
 (0)