From e7e30a46c20dd93902fda7cc26d0070492ccb54a Mon Sep 17 00:00:00 2001 From: Charles Milette Date: Mon, 19 Nov 2018 14:32:16 -0500 Subject: [PATCH] Use ToInt64 --- ShareX/Forms/MainForm.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ShareX/Forms/MainForm.cs b/ShareX/Forms/MainForm.cs index 49fb9f640..cea13dc6a 100644 --- a/ShareX/Forms/MainForm.cs +++ b/ShareX/Forms/MainForm.cs @@ -302,9 +302,9 @@ protected override void WndProc(ref Message m) { if (m.Msg == (int)WindowsMessages.QUERYENDSESSION) { - // Casting to long before because the int conversion operator enforces checked semantics - // thus crashes any 64 bits build. IntPtr -> long and long -> enum doesn't. - EndSessionReasons reason = (EndSessionReasons)(long)(m.LParam); + // Calling ToInt64 because the int conversion operator (called when irectly casting the IntPtr to the enum) + // enforces checked semantics thus crashes any 64 bits build. ToInt64() and long -> enum conversion doesn't. + EndSessionReasons reason = (EndSessionReasons)m.LParam.ToInt64(); if (reason.HasFlag(EndSessionReasons.ENDSESSION_CLOSEAPP)) { // Register for restart. This allows our application to automatically restart when it is installing an update from the Store.