同步操作将从 Gitee 极速下载/fastgithub 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using Microsoft.Win32;using System;using System.Diagnostics;using System.IO;using System.Reflection;using System.Threading;using System.Windows;namespace FastGithub.UI{class Program{private const string MUTEX_NAME = "Global\\FastGithub.UI";private const string MAIN_WINDOWS = "MainWindow.xaml";private const string FASTGITHUB_PATH = "fastgithub.exe";[STAThread]static void Main(string[] args){AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;using var mutex = new Mutex(true, MUTEX_NAME, out var isFirstInstance);if (isFirstInstance == false){return;}StartFastGithub();SetWebBrowserDPI();SetWebBrowserVersion();var app = new Application();app.StartupUri = new Uri(MAIN_WINDOWS, UriKind.Relative);app.Run();}/// <summary>/// 程序集加载失败时/// </summary>/// <param name="sender"></param>/// <param name="args"></param>/// <returns></returns>private static Assembly? OnAssemblyResolve(object sender, ResolveEventArgs args){var name = new AssemblyName(args.Name).Name;if (name.EndsWith(".resources")){return default;}var stream = Application.GetResourceStream(new Uri($"Resource/{name}.dll", UriKind.Relative)).Stream;var buffer = new byte[stream.Length];stream.Read(buffer, 0, buffer.Length);return Assembly.Load(buffer);}/// <summary>/// 设置浏览器版本/// </summary>private static void SetWebBrowserVersion(){const string subKey = @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";var registryKey = Registry.CurrentUser.OpenSubKey(subKey, true);if (registryKey == null){registryKey = Registry.CurrentUser.CreateSubKey(subKey);}var name = $"{Process.GetCurrentProcess().ProcessName}.exe";using var webBrowser = new System.Windows.Forms.WebBrowser();var value = int.Parse($"{webBrowser.Version.Major}000");registryKey.SetValue(name, value, RegistryValueKind.DWord);}/// <summary>/// 设置浏览器DPI/// </summary>private static void SetWebBrowserDPI(){const string subKey = @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_96DPI_PIXEL";var registryKey = Registry.CurrentUser.OpenSubKey(subKey, true);if (registryKey == null){registryKey = Registry.CurrentUser.CreateSubKey(subKey);}var name = $"{Process.GetCurrentProcess().ProcessName}.exe";registryKey.SetValue(name, 1, RegistryValueKind.DWord);}/// <summary>/// 启动fastgithub/// </summary>/// <returns></returns>private static void StartFastGithub(){if (File.Exists(FASTGITHUB_PATH) == false){return;}var startInfo = new ProcessStartInfo{FileName = FASTGITHUB_PATH,Arguments = $"ParentProcessId={Process.GetCurrentProcess().Id} UdpLoggerPort={UdpLogger.Port}",UseShellExecute = false,CreateNoWindow = true};Process.Start(startInfo);}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。