summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Utilities/UwpDetect.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-08-18 21:50:54 +0100
committersr55 <[email protected]>2017-08-18 21:50:54 +0100
commit63add3c308571c1018fd1f8801100ead98e989b4 (patch)
tree65830fd0bbe9d5504038dcf176a579029abf0a2f /win/CS/HandBrakeWPF/Utilities/UwpDetect.cs
parenta5d09db0caec7c880e9b280d72a2fafeb122815b (diff)
WinGui: Make the app UWP aware. When in a UWP container, the update options will now be disabled.
Diffstat (limited to 'win/CS/HandBrakeWPF/Utilities/UwpDetect.cs')
-rw-r--r--win/CS/HandBrakeWPF/Utilities/UwpDetect.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Utilities/UwpDetect.cs b/win/CS/HandBrakeWPF/Utilities/UwpDetect.cs
new file mode 100644
index 000000000..068165924
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Utilities/UwpDetect.cs
@@ -0,0 +1,40 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="UwpDetect.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Helper class to detect if we are running in a UWP container.
+// https://msdn.microsoft.com/en-us/library/windows/desktop/hh446599(v=vs.85).aspx
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Utilities
+{
+ using System;
+ using System.Runtime.InteropServices;
+
+ public class UwpDetect
+ {
+ [DllImport("kernel32.dll")]
+ static extern int GetCurrentPackageFullName(ref int length, IntPtr fullName);
+
+ public static bool IsUWP()
+ {
+ if (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor <= 1)
+ {
+ return false;
+ }
+
+ int length = 0;
+ IntPtr name = IntPtr.Zero;
+ GetCurrentPackageFullName(ref length, name); // Only available in 6.2 or later.
+
+ if (length > 0)
+ {
+ return true;
+ }
+
+ return false;
+ }
+ }
+}