Files
lserp_cs_5.0/插件库/cwber/common/BrowserProcessHandler.cs
T
2026-07-10 15:25:05 +08:00

36 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Cef3;
namespace Sashulin.common
{
internal sealed class BrowserProcessHandler : CefBrowserProcessHandler
{
protected override void OnBeforeChildProcessLaunch(CefCommandLine commandLine)
{
Console.WriteLine("AppendExtraCommandLineSwitches: {0}", commandLine);
Console.WriteLine(" Program == {0}", commandLine.GetProgram());
// .NET in Windows treat assemblies as native images, so no any magic required.
// Mono on any platform usually located far away from entry assembly, so we want prepare command line to call it correctly.
if (Type.GetType("Mono.Runtime") != null)
{
if (!commandLine.HasSwitch("cefglue"))
{
var path = new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath;
commandLine.SetProgram(path);
var mono = CefRuntime.Platform == CefRuntimePlatform.Linux ? "/usr/bin/mono" : @"C:\Program Files\Mono-2.10.8\bin\monow.exe";
commandLine.PrependArgument(mono);
commandLine.AppendSwitch("cefglue", "w");
}
}
Console.WriteLine(" -> {0}", commandLine);
}
}
}