mirror of
https://github.com/chylex/TweetDuck.git
synced 2024-11-14 17:42:47 +01:00
47 lines
1.7 KiB
C#
47 lines
1.7 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Runtime.InteropServices;
|
|
using CefSharp;
|
|
using CefSharp.BrowserSubprocess;
|
|
|
|
namespace TweetDuck.Browser{
|
|
static class Program{
|
|
internal const string Version = "1.2.1.0";
|
|
|
|
private static int Main(string[] args){
|
|
SubProcess.EnableHighDPISupport();
|
|
|
|
const string typePrefix = "--type=";
|
|
string type = Array.Find(args, arg => arg.StartsWith(typePrefix, StringComparison.OrdinalIgnoreCase)).Substring(typePrefix.Length);
|
|
|
|
if (type == "renderer"){
|
|
using(RendererProcess subProcess = new RendererProcess(args)){
|
|
return subProcess.Run();
|
|
}
|
|
}
|
|
else return SubProcess.ExecuteProcess();
|
|
}
|
|
|
|
private sealed class RendererProcess : SubProcess{
|
|
// ReSharper disable once ParameterTypeCanBeEnumerable.Local
|
|
public RendererProcess(string[] args) : base(args){}
|
|
|
|
public override void OnBrowserCreated(CefBrowserWrapper wrapper){
|
|
base.OnBrowserCreated(wrapper);
|
|
|
|
using(Process me = Process.GetCurrentProcess()){
|
|
PostMessage(HWND_BROADCAST, RegisterWindowMessage("TweetDuckSubProcess"), new UIntPtr((uint)me.Id), new IntPtr(wrapper.BrowserId));
|
|
}
|
|
}
|
|
}
|
|
|
|
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xFFFF);
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern bool PostMessage(IntPtr hWnd, uint msg, UIntPtr wParam, IntPtr lParam);
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern uint RegisterWindowMessage(string messageName);
|
|
}
|
|
}
|