There is no example how to detect if headphones are plugged in or not via C#.
I assume should be some event for that...
Does make sense to use WMI?
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\cimv2",
"SELECT * FROM Win32_SoundDevice");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_SoundDevice instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("StatusInfo: {0}", queryObj["StatusInfo"]);
}
Would anyone be so pleased to provide it?
Thank you!
Detecting changes of this kind is possible by using the IMMDeviceEnumerator::RegisterEndpointNotificationCallback method.
As you want to handle this in C# you will need a managed wrapper which has already been implemented by Akos Mattiassich. You can find a thourough example here: Managed Wrapper around MMAudioDeviceApi
He states: