Register for device listener on startup

This commit is contained in:
IceStormNG
2023-07-23 10:55:06 +02:00
parent d8b2836819
commit df616b486d

View File

@@ -4,6 +4,7 @@ using GHelper.Gpu;
using GHelper.Helpers;
using GHelper.Input;
using GHelper.Mode;
using GHelper.Peripherals;
using Microsoft.Win32;
using Ryzen;
using System.Diagnostics;
@@ -108,6 +109,9 @@ namespace GHelper
unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(settingsForm.Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
Task task = Task.Run((Action)PeripheralsProvider.DetectAllAsusMice);
PeripheralsProvider.RegisterForDeviceEvents();
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0)
{
SettingsToggle(action);
@@ -241,6 +245,7 @@ namespace GHelper
static void OnExit(object sender, EventArgs e)
{
trayIcon.Visible = false;
PeripheralsProvider.UnregisterForDeviceEvents();
clamshellControl.UnregisterDisplayEvents();
NativeMethods.UnregisterPowerSettingNotification(unRegPowerNotify);
Application.Exit();