This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::sync::RwLock; | |
fn main() { | |
let connection = Connection::new(); | |
// Depends on `Send` to move the connection "onto" the thread. | |
let thread = std::thread::spawn(move || { | |
connection.write(); | |
println!("{}", connection.read()); | |
// The connection is dropped here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use windows::{ | |
core::{HSTRING, PWSTR}, | |
Win32::Foundation::UNICODE_STRING, | |
}; | |
fn main() { | |
let us = UnicodeString::new("hello world"); | |
dbg!(&us); | |
unsafe { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace winrt; | |
using namespace Windows::Foundation; | |
struct Base: implements<Base, composable, IStringable> | |
{ | |
static IInspectable CreateInstance(IInspectable const& base, IInspectable& inner) | |
{ | |
return impl::composable_factory<Base>::CreateInstance<IInspectable>(base, inner); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\git\scratch10>type src\main.rs | |
use windows_sys::{core::*, Win32::System::LibraryLoader::*}; | |
fn main() { | |
unsafe { | |
let module = LoadLibraryExW( | |
w!("api-ms-win-core-com-l1-1-3.dll"), | |
core::ptr::null_mut(), | |
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS, | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use windows_core::*; | |
#[interface("1bd72b4b-8d05-44c6-8909-da3e0e91afa0")] | |
unsafe trait IDebug: IUnknown { | |
fn debug_carrot(&self, carrot: Ref<ICarrot>) -> Result<()>; | |
fn debug_pear(&self, pear: Ref<IPear>) -> Result<()>; | |
} | |
#[interface("3bde3f9e-4d7c-4d5f-8322-4b226e0e1b91")] | |
unsafe trait ICarrot: IUnknown { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use windows::{core::*, Win32::Storage::FileSystem::*}; | |
fn search_path(filename: &str) -> Result<String> { | |
let filename = &HSTRING::from(filename); | |
let len = unsafe { SearchPathW(None, filename, None, None, None) }; | |
if len == 0 { | |
return Err(Error::from_win32()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use windows::core::*; | |
use windows::Win32::System::Com::*; | |
use windows::Win32::UI::Accessibility::*; | |
use windows::Win32::UI::WindowsAndMessaging::*; | |
fn main() -> Result<()> { | |
unsafe { | |
let mut acc: Option<IAccessible> = None; | |
AccessibleObjectFromWindow( | |
GetDesktopWindow(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[dependencies.windows] | |
version = "0.52" | |
features = [ | |
"Win32_Foundation", | |
"Win32_System_LibraryLoader", | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[dependencies.windows] | |
version = "0.51" | |
features = ["Win32_Foundation", "Win32_System_SystemInformation", "Wdk_System_SystemServices"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pch.h" | |
using namespace winrt; | |
using namespace Windows::Foundation; | |
IAsyncAction Sample() | |
{ | |
throw winrt::hresult_invalid_argument(L"yolo"); | |
} |
NewerOlder