Dot-Net

如何在 WebBrowser 控制項中禁用點擊聲音

  • December 25, 2008

我使用 Javascript 點擊 webbrowser 控制項中的連結。但我不想听到 IE 的“咔噠”聲。

有沒有辦法做到這一點?

附言

對於 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);

(作為 WPF 團隊的解決方案在 MS 回饋站點上找到:https ://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=345528&wa=wsignin1.0 )

引用自:https://stackoverflow.com/questions/393166