12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Diagnostics;
- using System.Windows.Forms;
- namespace CustomUrlSchemeRegistrationPoC
- {
- public partial class UriPocForm : Form
- {
- public UriPocForm()
- {
- InitializeComponent();
- }
- private void InstallButton_Click(object sender, EventArgs e)
- {
- var registration = new CustomUriSchemeRegistration(SchemeTextBox.Text, DisplayTextBox.Text, Application.ExecutablePath);
- if (registration.Install(out var err)) MessageBox.Show("Success", "Install");
- else MessageBox.Show(err.ToString(), "Install");
- }
- private void UninstallButton_Click(object sender, EventArgs e)
- {
- var registration = new CustomUriSchemeRegistration(SchemeTextBox.Text, DisplayTextBox.Text, Application.ExecutablePath);
- if (registration.Uninstall(out var err)) MessageBox.Show("Success", "Uninstall");
- else MessageBox.Show(err.ToString(), "Uninstall");
- }
- private void TryCallButton_Click(object sender, EventArgs e)
- {
- try
- {
- var process = Process.Start($"{SchemeTextBox.Text}://{TryCallArgsTextBox.Text}");
- if (null == process)
- {
- MessageBox.Show("Unknown result", "Try Call");
- }
- else
- {
- process.WaitForExit();
- MessageBox.Show("Success", "Try Call");
- }
- }
- catch (Exception err)
- {
- MessageBox.Show(err.ToString(), "Try Call");
- }
- }
- }
- }
|