gpt4 book ai didi

.net - 如何在 WebBrowser Control 中禁用点击声音

转载 作者:行者123 更新时间:2023-12-03 11:05:40 24 4
gpt4 key购买 nike

我使用 Javascript 单击 webbrowser 控件中的链接。但我不想听到 IE 的“咔嗒”声。

有没有办法做到这一点?

附言

  • 我不想更改系统设置。
  • 我见过这个( HowTo Disable WebBrowser 'Click Sound' in your app only ),但 Document.Write 不是我的选择。
  • 最佳答案

    对于 IE7 及以上,你可以使用这个:

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

    使用以下 DLL 导入
    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);

    (在 MS 反馈站点上找到,作为 WPF 团队的解决方案: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345528&wa=wsignin1.0)

    关于.net - 如何在 WebBrowser Control 中禁用点击声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/393166/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com