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
{ | |
"Windows.AI.MachineLearning": { | |
"Windows.Foundation", | |
"Windows.Foundation.Collections", | |
}, | |
"Windows.AI.MachineLearning.Preview": { | |
"Windows.Foundation.Collections", | |
}, | |
"Windows.ApplicationModel.AppService": { | |
"Windows.Foundation", |
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 bindings::windows::storage::UserDataPaths; | |
fn main() -> windows::Result<()> { | |
let path = UserDataPaths::get_default()?.local_app_data()?; | |
println!("{}", path); | |
Ok(()) | |
} |
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 bindings::{ | |
windows::win32::com::CoTaskMemFree, | |
windows::win32::shell::SHGetKnownFolderPath, | |
windows::win32::system_services::{HANDLE, PWSTR}, | |
}; | |
fn known_folder_path(id: &windows::Guid) -> windows::Result<String> { | |
unsafe { | |
let mut path = PWSTR::default(); | |
SHGetKnownFolderPath(id, 0, HANDLE(0), &mut path).ok()?; |
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 bindings::{windows::win32::intl::*, windows::*}; | |
fn main() -> Result<()> { | |
initialize_mta()?; | |
let factory: ISpellCheckerFactory = create_instance(&SpellCheckerFactory)?; | |
let locale = HString::from("en-US"); | |
let mut supported = FALSE; | |
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
winrt::declare!( | |
// A WinRT struct defined here | |
pub struct StructType { x: i32, y: i32 }; | |
// A WinRT interface defined here (uuid is inferred) | |
// Implemented by the class itself. | |
pub interface IClassType { | |
fn method(&self) -> Result<i32>; | |
} |
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
com::declare!( | |
// A COM interface | |
[uuid(...)] | |
pub interface IComInterface { | |
fn foo(&self); | |
fn bar(&self); | |
} | |
// A public COM class must have a [uuid] |
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
com::declare!( | |
// A COM interface declared here | |
[uuid(...)] | |
interface IOldSchool {...} | |
// A COM class declared here (not defined here) | |
[uuid(...)] | |
class ExternalClass : IOldSchool; |
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 <Unknwn.h> | |
#include <winrt/Windows.Foundation.h> | |
using namespace winrt; | |
using namespace Windows::Foundation; | |
static constexpr GUID server_clsid // DAA16D7F-EF66-4FC9-B6F2-3E5B6D924576 | |
{ | |
0xdaa16d7f, 0xef66, 0x4fc9, { 0xb6, 0xf2, 0x3e, 0x5b, 0x6d, 0x92, 0x45, 0x76 } | |
}; |
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 <Unknwn.h> | |
#include <winrt/Windows.Foundation.h> | |
using namespace winrt; | |
using namespace Windows::Foundation; | |
struct Stringable : implements<Stringable, IStringable> | |
{ | |
hstring ToString() | |
{ |
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 "winrt/Windows.Foundation.h" | |
using namespace winrt; | |
using namespace Windows::Foundation; | |
using namespace std::chrono; | |
IAsyncAction wait_for(TimeSpan duration) | |
{ | |
co_await duration; | |
printf("done %lld\n", duration.count()); |