HowTo Disable WebBrowser 'Click Sound' in your app only

前端 未结 5 527
南旧
南旧 2020-12-05 17:52

The \'click sound\' in question is actually a system wide preference, so I only want it to be disabled when my application has focus and then re-enable when the application

5条回答
  •  一向
    一向 (楼主)
    2020-12-05 18:40

    const int FEATURE_DISABLE_NAVIGATION_SOUNDS = 21;
    const int SET_FEATURE_ON_PROCESS = 0x00000002;
    
    [DllImport("urlmon.dll")]
    [PreserveSig]
    [return: MarshalAs(UnmanagedType.Error)]
    static extern int CoInternetSetFeatureEnabled(int FeatureEntry,
                                                  [MarshalAs(UnmanagedType.U4)] int dwFlags,
                                                  bool fEnable);
    
    static void DisableClickSounds()
    {
        CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS,
                                    SET_FEATURE_ON_PROCESS,
                                    true);
    }
    

提交回复
热议问题