wasSharpNET

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 25  →  ?path2? @ 26
/Platform/Windows/Utilities.cs
@@ -0,0 +1,44 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 //
// Please see: http://www.gnu.org/licenses/gpl.html for legal details, //
// rights of fair usage, the disclaimer and warranty conditions. //
///////////////////////////////////////////////////////////////////////////
 
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
 
namespace wasSharpNET.Platform.Windows
{
public static class Utilities
{
public static bool ElevatePrivileges()
{
try
{
// Create an elevated process with the original arguments.
var info = new ProcessStartInfo(Assembly.GetEntryAssembly().Location,
string.Join(@" ", Environment.CommandLine.Split(' ').Skip(1)))
{
Verb = "runas" // indicates to elevate privileges
};
 
var process = new System.Diagnostics.Process
{
EnableRaisingEvents = true, // enable WaitForExit()
StartInfo = info
};
 
process.Start();
process.WaitForExit();
}
catch (Exception)
{
return false;
}
 
return true;
}
}
}
/wasSharpNET.csproj
@@ -59,6 +59,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Serialization\XmlSerializerCache.cs" />
<Compile Include="Syndication\ObservableSyndication.cs" />
<Compile Include="Platform\Windows\Utilities.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\wasSharp\wasSharp.csproj">