Speakers / headphones switching detection

Is there any universal way to detect speakers/headphones switching when e.g. user plugs headphones jack into computer? I’ve found that for some Realtek drivers:

  • we can listen for some property change by implementing IMMNotificationClient.
  • we can check MMDevice property in the registry, e.g. HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\{GUID}\FxProperties\{be8db2aa-0e62-4e79-8279-992034e0308b},0
  • we can investigate IDeviceTopology / IConnector / IPart / IKsJackDescription / IKsJackDescription2 configuration, but I’m not sure if there is any way of getting notified for changes.

All of this can work on one computer and it doesn’t work on others. Any ideas for more or less generic solution?