C# 禁止WebBrowser网页跳转时发出的声音
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); }
默认情况下,IE内核的网页浏览框(WebBrowser、CHtmlView、CHtmlDialog等控件)在跳转网页、点击按钮时会发出声音,用CoInternetSetFeatureEnabled这个API可以禁止掉。