Scaffolding for COM work

This commit is contained in:
Your Name
2022-06-12 16:01:40 -04:00
parent fb172f673e
commit 6c50e23b47
3 changed files with 60 additions and 0 deletions

17
Cargo.lock generated
View File

@@ -82,6 +82,7 @@ version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647"
dependencies = [
"windows-implement",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
@@ -89,6 +90,22 @@ dependencies = [
"windows_x86_64_msvc",
]
[[package]]
name = "windows-implement"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67a1062e555f7d9d66fd1130ed4f7c6ec41a47529ee0850cd0e926d95b26bb14"
dependencies = [
"syn",
"windows-tokens",
]
[[package]]
name = "windows-tokens"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3263d25f1170419995b78ff10c06b949e8a986c35c208dc24333c64753a87169"
[[package]]
name = "windows_aarch64_msvc"
version = "0.37.0"

View File

@@ -12,6 +12,9 @@ com = {version="0.6.0", features=["production"]}
version = "0.37.0"
features = [
"alloc",
"implement",
"Win32_Media_Audio",
"Win32_UI_Shell_PropertiesSystem",
"Data_Xml_Dom",
"Win32_UI",
"Win32_UI_Accessibility",

View File

@@ -2,6 +2,7 @@ mod pid_to_exe;
use windows::Win32::{
Foundation::{HINSTANCE, HWND},
Media::Audio::{IMMNotificationClient, IMMNotificationClient_Impl},
UI::{
Accessibility::{SetWinEventHook, HWINEVENTHOOK},
WindowsAndMessaging::{
@@ -58,6 +59,45 @@ fn win_event_hook_loop() {
}
}
}
#[windows::core::implement(IMMNotificationClient)]
struct DeviceNotification;
impl IMMNotificationClient_Impl for DeviceNotification {
fn OnDeviceStateChanged(
&self,
pwstrdeviceid: &windows::core::PCWSTR,
dwnewstate: u32,
) -> windows::core::Result<()> {
Ok(())
}
fn OnDeviceAdded(&self, pwstrdeviceid: &windows::core::PCWSTR) -> windows::core::Result<()> {
Ok(())
}
fn OnDeviceRemoved(&self, pwstrdeviceid: &windows::core::PCWSTR) -> windows::core::Result<()> {
Ok(())
}
fn OnDefaultDeviceChanged(
&self,
flow: windows::Win32::Media::Audio::EDataFlow,
role: windows::Win32::Media::Audio::ERole,
pwstrdefaultdeviceid: &windows::core::PCWSTR,
) -> windows::core::Result<()> {
Ok(())
}
fn OnPropertyValueChanged(
&self,
pwstrdeviceid: &windows::core::PCWSTR,
key: &windows::Win32::UI::Shell::PropertiesSystem::PROPERTYKEY,
) -> windows::core::Result<()> {
Ok(())
}
}
fn main() {
win_event_hook_loop();
}