How to disable click sound in WebBrowser Control

前端 未结 7 1343
庸人自扰
庸人自扰 2020-11-29 02:11

I use Javascript to click a link in the webbrowser control. But I don\'t want to hear IE\'s \"click\" sound.

Is there any way to do this?

P.S.

7条回答
  •  生来不讨喜
    2020-11-29 02:29

    For IE7 and above, you can use this:

    int feature = FEATURE_DISABLE_NAVIGATION_SOUNDS;
    CoInternetSetFeatureEnabled(feature, SET_FEATURE_ON_PROCESS, true);
    

    using the following DLL imports

    private const int FEATURE_DISABLE_NAVIGATION_SOUNDS = 21;
    private const int SET_FEATURE_ON_THREAD = 0x00000001;
    private const int SET_FEATURE_ON_PROCESS = 0x00000002;
    private const int SET_FEATURE_IN_REGISTRY = 0x00000004;
    private const int SET_FEATURE_ON_THREAD_LOCALMACHINE = 0x00000008;
    private const int SET_FEATURE_ON_THREAD_INTRANET = 0x00000010;
    private const int SET_FEATURE_ON_THREAD_TRUSTED = 0x00000020;
    private const int SET_FEATURE_ON_THREAD_INTERNET = 0x00000040;
    private const int SET_FEATURE_ON_THREAD_RESTRICTED = 0x00000080;
    
    ...
    
    [DllImport("urlmon.dll")]
    [PreserveSig]
    [return:MarshalAs(UnmanagedType.Error)]
    static extern int CoInternetSetFeatureEnabled(
    int FeatureEntry,
    [MarshalAs(UnmanagedType.U4)] int dwFlags,
    bool fEnable);
    

    (found on the MS feedback site as a solution from the WPF team: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345528&wa=wsignin1.0)

提交回复
热议问题