diff --git a/Cargo.lock b/Cargo.lock index 69ca531..fcc2831 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/Cargo.toml b/Cargo.toml index 3cd6e58..f4cdc07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", diff --git a/src/main.rs b/src/main.rs index 04e0109..cc2aabf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(); }