2020-05-09 14:26:37 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2020-05-09 16:36:14 +02:00
|
|
|
|
using System.Diagnostics;
|
2020-05-10 13:27:39 +02:00
|
|
|
|
using System.IO;
|
2020-05-09 14:26:37 +02:00
|
|
|
|
using System.Linq;
|
2020-05-10 13:27:39 +02:00
|
|
|
|
using System.Reflection;
|
2020-05-09 14:26:37 +02:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2020-05-09 16:36:14 +02:00
|
|
|
|
using Microsoft.Win32;
|
2020-05-09 14:26:37 +02:00
|
|
|
|
|
|
|
|
|
namespace CompressH265 {
|
|
|
|
|
static class Program {
|
2020-05-09 18:46:44 +02:00
|
|
|
|
private static string subkey = "*\\shell\\Compress to H.265 (HEVC)";
|
|
|
|
|
|
2020-05-09 14:26:37 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The main entry point for the application.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[STAThread]
|
2020-05-09 16:36:14 +02:00
|
|
|
|
static void Main(string[] args) {
|
2020-05-10 13:27:39 +02:00
|
|
|
|
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
|
|
|
|
|
|
|
|
if (path != null) {
|
|
|
|
|
Environment.CurrentDirectory = path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-05-09 16:36:14 +02:00
|
|
|
|
foreach(var item in args)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(item);
|
|
|
|
|
|
|
|
|
|
if (item == "-contextmenu") {
|
|
|
|
|
installContextMenu();
|
|
|
|
|
System.Environment.Exit(1);
|
2020-05-09 18:46:44 +02:00
|
|
|
|
} else if (item == "-uninstallcontextmenu") {
|
|
|
|
|
uninstallContextMenu();
|
|
|
|
|
System.Environment.Exit(1);
|
2020-05-09 16:36:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-09 14:26:37 +02:00
|
|
|
|
// ***this line is added***
|
|
|
|
|
if (Environment.OSVersion.Version.Major >= 6)
|
|
|
|
|
SetProcessDPIAware();
|
|
|
|
|
|
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
|
Application.Run(new Form1());
|
2020-05-09 16:36:14 +02:00
|
|
|
|
|
|
|
|
|
|
2020-05-09 14:26:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***also dllimport of that function***
|
|
|
|
|
[System.Runtime.InteropServices.DllImport("user32.dll")]
|
|
|
|
|
private static extern bool SetProcessDPIAware();
|
2020-05-09 16:36:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void installContextMenu() {
|
|
|
|
|
RegistryKey item = null;
|
|
|
|
|
try {
|
2020-05-09 18:46:44 +02:00
|
|
|
|
item = Registry.ClassesRoot.CreateSubKey(subkey + "\\command");
|
2020-05-09 16:36:14 +02:00
|
|
|
|
item.SetValue("", System.Reflection.Assembly.GetExecutingAssembly().Location + " -i \"%1\"");
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if(item != null)
|
|
|
|
|
item.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-09 18:46:44 +02:00
|
|
|
|
|
|
|
|
|
public static void uninstallContextMenu() {
|
|
|
|
|
Registry.ClassesRoot.DeleteSubKeyTree(subkey);
|
|
|
|
|
}
|
2020-05-09 14:26:37 +02:00
|
|
|
|
}
|
|
|
|
|
}
|