zoukankan      html  css  js  c++  java
  • C# : CEF操作

    代码挺差的,仅供学习、参考

        class CEFGlueLoader
        {
            class CefAppImpl : CefApp
            {
                protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
                {
                    commandLine.AppendArgument("enable-npapi");
                    commandLine.AppendSwitch("enable-media-stream", "enable-media-stream");
                    commandLine.AppendSwitch("process-per-site");
                    commandLine.AppendSwitch("ppapi-flash-version", "23.0.0.185");//PepperFlashmanifest.json中的version
                    commandLine.AppendSwitch("ppapi-flash-path", "PepperFlash\pepflashplayer.dll");
                }
            }
    
            public static void InitCEF()
            {
    #if !_ORG_MANAGER && !_MBMAKER
                CefRuntime.Load();
                string[] args = new string[0];
                var mainArgs = new CefMainArgs(args);
                var app = new CefAppImpl();
                var exitCode = CefRuntime.ExecuteProcess(mainArgs, app);
                System.Diagnostics.Trace.WriteLine("CefRuntime.ExecuteProcess return: " + exitCode);
                if (exitCode != -1)
                {
                    return;
                }
    
                var settings = new CefSettings
                {
                    BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"binCef3Process.exe"),
                    SingleProcess = false,
                    MultiThreadedMessageLoop = true,
                    LogSeverity = CefLogSeverity.Default,
                    LogFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"logCefGlue.log"),
                    CachePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"cache"),
                    CommandLineArgsDisabled = true,
                    Locale = "zh_CN",
                    LocalesDirPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"binlocales"),
                    RemoteDebuggingPort = 7789,
                    
                };
                CefRuntime.Initialize(mainArgs, settings, app);
    
                if (!settings.MultiThreadedMessageLoop)
                {
                    System.Windows.Forms.Application.Idle += (sender, e) => { CefRuntime.DoMessageLoopWork(); };
                }
    #endif
            }
    
            private static string GetPath(string v)
            {
                return Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, v));
            }
    
            public static void ShutDownCEF()
            {
    #if !_ORG_MANAGER && !_MBMAKER 
                try
                {
                    CefRuntime.Shutdown();
                }
                catch (Exception)
                {                
                }
    #endif
            }
        }
    View Code
  • 相关阅读:
    Microsoft.mshtml到底是什么?
    编译.NET程序自动产生版本号的规则
    VB.NET(2005)中关于dll调用的错误信息(转)
    C# RichTextBox控件 滚动条 自动移至 最后一条记录处
    如何刪除richtextbox最後一行
    Using Hudson for C++/CMake/CppUnit
    让开发自动化: 选择持续集成服务器
    C#加载窗体错误
    各种CI工具对比表
    用 Hudson 实现 Visual Studio (C++) 项目的 daily build
  • 原文地址:https://www.cnblogs.com/shenchao/p/6211941.html
Copyright © 2011-2022 走看看