![]() |
|
[VB.Net, C#] Disable Sound of the WebBrowser Control - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework) +--- Thread: [VB.Net, C#] Disable Sound of the WebBrowser Control (/Thread-VB-Net-C-Disable-Sound-of-the-WebBrowser-Control) |
[VB.Net, C#] Disable Sound of the WebBrowser Control - Coder-san - 03-07-2011 Disable Sound of the WebBrowser Control WebBrowser Control is very useful at times, but people avoid it because of the annoying IE Navigation sound it makes. There is a way to disable navigation sounds correctly TEMPORARILY. Yes, you won't have to delete a file, or mess with a user's Registry. For the code below, credits go to [link=http://stackoverflow.com/users/33682/james-crowley]James Crowley[/link] at [link=http://stackoverflow.com/questions/393166/how-to-disable-click-sound-in-webbrowser-control/737280#737280]stackOverflow[/link] Visual Basic .Net Code: Imports System.Runtime.InteropServices
Public Class Form1
Private Const DISABLE_SOUNDS As Integer = 21
Private Const SET_FEATURE_ON_PROCESS As Integer = 2
<DllImport("urlmon.dll")> _
Public Shared Function CoInternetSetFeatureEnabled( _
ByVal FeatureEntry As Integer, <MarshalAs(UnmanagedType.U4)> ByVal dwFlags As Integer, ByVal fEnable As Boolean) As Integer
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
CoInternetSetFeatureEnabled(DISABLE_SOUNDS, SET_FEATURE_ON_PROCESS, True)
Dim web as New WebBrowser
web.Navigate("http://www.google.com")
End Sub
End ClassC# Code: private const int DISABLE_NAVIGATION_SOUNDS = 21;
private 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);Usage: Code: CoInternetSetFeatureEnabled(DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_PROCESS, true); |