zoukankan      html  css  js  c++  java
  • WebBrowser静音(静Flash声音及刷新出现的哒哒哒声音)

            static class NativeMethods
            {
                [DllImport("winmm.dll", EntryPoint = "waveOutSetVolume")]
                public static extern int WaveOutSetVolume(IntPtr hwo, uint dwVolume);
    
            }

    调用:

    NativeMethods.WaveOutSetVolume(IntPtr.Zero,音量大小)

    windows7下测试通过,因为win7有增强型音量控制, 不清楚xp下行不行, 待会虚拟机上测试。



    禁止webbrowser点击、刷新时出现的声音。

     public static class UnmanagedCode
        {
    
            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)]
            public static extern int CoInternetSetFeatureEnabled(int FeatureEntry, [MarshalAs(UnmanagedType.U4)] int dwFlags, bool fEnable);
            public static void DisableSound()
            {
                UnmanagedCode.CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_THREAD, true);
                UnmanagedCode.CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_PROCESS, true);
                UnmanagedCode.CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_IN_REGISTRY, true);
                UnmanagedCode.CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_THREAD_LOCALMACHINE, true);
                UnmanagedCode.CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_THREAD_INTRANET, true);
                UnmanagedCode.CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_THREAD_TRUSTED, true);
                UnmanagedCode.CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_THREAD_INTERNET, true);
                UnmanagedCode.CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_THREAD_RESTRICTED, true);
            }
        }

    调用: UnmanagedCode.DisableSound();

    就可以了。 

     
  • 相关阅读:
    阿里云ECS7天训练营——05基于ECS搭建Java Web开发环境
    阿里云ECS7天训练营——04打造离线下载服务器
    阿里云ECS7天训练营——02搭建wiki知识库
    阿里云ECS7天训练营——03基于云服务器构建微信公众号管理系统
    阿里云ECS7天训练营——01打造专属云笔记
    Spring Cloud Config实现配置中心
    shell脚本条件判断if中-a到-z的意思
    Linux定时任务Crontab命令详解
    Linux下的tar压缩解压缩命令详解
    谈谈注册中心 zookeeper 和 eureka中的CP和 AP
  • 原文地址:https://www.cnblogs.com/jackrebel/p/3049115.html
Copyright © 2011-2022 走看看