mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-03-28 15:35:02 +01:00
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using CommonHelpers;
|
|
using Microsoft.Win32;
|
|
|
|
namespace PerformanceOverlay
|
|
{
|
|
internal static class UriProtocolRegistration
|
|
{
|
|
private const string ProtocolKey = @"Software\Classes\steamdecktools-performanceoverlay";
|
|
|
|
public static void EnsureRegistered()
|
|
{
|
|
try
|
|
{
|
|
var exePath = Environment.ProcessPath;
|
|
if (String.IsNullOrWhiteSpace(exePath))
|
|
return;
|
|
|
|
using var protocol = Registry.CurrentUser.CreateSubKey(ProtocolKey);
|
|
if (protocol is null)
|
|
return;
|
|
|
|
protocol.SetValue("", "URL:Steam Deck Tools Performance Overlay");
|
|
protocol.SetValue("URL Protocol", "");
|
|
|
|
using var icon = protocol.CreateSubKey("DefaultIcon");
|
|
icon?.SetValue("", "\"" + exePath + "\",0");
|
|
|
|
using var command = protocol.CreateSubKey(@"shell\open\command");
|
|
command?.SetValue("", "\"" + exePath + "\" \"%1\"");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.TraceLine("UriProtocolRegistration: {0}", ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|