wasSharpNET – Blame information for rev 27

Subversion Repositories:
Rev:
Rev Author Line No. Line
26 office 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 //
3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, //
4 // rights of fair usage, the disclaimer and warranty conditions. //
5 ///////////////////////////////////////////////////////////////////////////
6  
7 using System;
8 using System.Diagnostics;
9 using System.Linq;
10 using System.Reflection;
11  
12 namespace wasSharpNET.Platform.Windows
13 {
14 public static class Utilities
15 {
16 public static bool ElevatePrivileges()
17 {
18 try
19 {
20 // Create an elevated process with the original arguments.
21 var info = new ProcessStartInfo(Assembly.GetEntryAssembly().Location,
22 string.Join(@" ", Environment.CommandLine.Split(' ').Skip(1)))
23 {
24 Verb = "runas" // indicates to elevate privileges
25 };
26  
27 var process = new System.Diagnostics.Process
28 {
29 EnableRaisingEvents = true, // enable WaitForExit()
30 StartInfo = info
31 };
32  
33 process.Start();
34 process.WaitForExit();
35 }
36 catch (Exception)
37 {
38 return false;
39 }
40  
41 return true;
42 }
27 office 43  
44 public static bool isWindows()
45 {
46 return Environment.OSVersion.Platform.Equals(PlatformID.Win32NT) ||
47 Environment.OSVersion.Platform.Equals(PlatformID.Win32S) ||
48 Environment.OSVersion.Platform.Equals(PlatformID.Win32Windows) ||
49 Environment.OSVersion.Platform.Equals(PlatformID.WinCE);
50 }
26 office 51 }
52 }