Added UnregisterNotify call

This commit is contained in:
Travis Nickles 2018-10-16 23:06:39 -05:00
parent 2029cc5531
commit 7d871c0709

View File

@ -62,8 +62,9 @@ namespace DS4Windows
{ "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion,
string.Empty, string.Empty, string.Empty, string.Empty };
internal const string UPDATER_VERSION = "1.2.8.0";
internal static int WM_QUERYENDSESSION = 0x11;
private const string UPDATER_VERSION = "1.2.8.0";
private const int WM_QUERYENDSESSION = 0x11;
private const int WM_CLOSE = 0x10;
internal string updaterExe = Environment.Is64BitProcess ? "DS4Updater.exe" : "DS4Updater_x86.exe";
[DllImport("user32.dll")]
@ -1041,7 +1042,9 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
private const int DBT_DEVICEREMOVECOMPLETE = 0x8004;
protected override void WndProc(ref Message m)
{
if (m.Msg == ScpDevice.WM_CREATE)
switch (m.Msg)
{
case ScpDevice.WM_CREATE:
{
Guid hidGuid = new Guid();
NativeMethods.HidD_GetHidGuid(ref hidGuid);
@ -1052,8 +1055,9 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
ScpForm_Closing(this,
new FormClosingEventArgs(CloseReason.ApplicationExitCall, false));
}
break;
}
else if (m.Msg == ScpDevice.WM_DEVICECHANGE)
case ScpDevice.WM_DEVICECHANGE:
{
if (runHotPlug)
{
@ -1073,10 +1077,20 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
}
}
}
break;
}
if (m.Msg == WM_QUERYENDSESSION)
case WM_CLOSE:
{
ScpDevice.UnregisterNotify(Handle);
break;
}
case WM_QUERYENDSESSION:
{
systemShutdown = true;
break;
}
default: break;
}
// If this is WM_QUERYENDSESSION, the closing event should be
// raised in the base WndProc.