禁止WebBrowser网页跳转时发出的声音

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

VC/C++代码:

#include <urlmon.h>
#ifndef FEATURE_DISABLE_NAVIGATION_SOUNDS
#define FEATURE_DISABLE_NAVIGATION_SOUNDS 21
#endif
#ifndef SET_FEATURE_ON_PROCESS
#define SET_FEATURE_ON_PROCESS 0x00000002
#endif

void DisableClickSounds()  
{  
	CoInternetSetFeatureEnabled((INTERNETFEATURELIST)FEATURE_DISABLE_NAVIGATION_SOUNDS,SET_FEATURE_ON_PROCESS,true);  
} 

C#代码:

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);
}

易语言代码:

.版本 2

.子程序 禁止网页跳转声音

CoInternetSetFeatureEnabled (#FEATURE_DISABLE_NAVIGATION_SOUNDS, #SET_FEATURE_ON_PROCESS, 1)

.DLL命令 CoInternetSetFeatureEnabled, 整数型, "urlmon", "CoInternetSetFeatureEnabled"
    .参数 FeatureEntry, 整数型, , INTERNETFEATURELIST
    .参数 dwFlags, 整数型, , DWORD
    .参数 fEnable, 整数型, , BOOL

.常量 FEATURE_DISABLE_NAVIGATION_SOUNDS, "21", , 禁止跳转声音
.常量 SET_FEATURE_ON_PROCESS, "2", , 仅对当前进程有效


阅读更多
换一批

没有更多推荐了,返回首页