Merge pull request #1 from EpicMorg/develop

1.0.0.0
This commit is contained in:
STAM 2020-02-18 14:07:25 +03:00 committed by GitHub
commit efca79da56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 4636 additions and 0 deletions

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29721.120
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "windows2go.switcher", "windows2go.switcher\windows2go.switcher.csproj", "{D5523217-5311-4230-B7B1-656E7F9817CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D5523217-5311-4230-B7B1-656E7F9817CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5523217-5311-4230-B7B1-656E7F9817CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5523217-5311-4230-B7B1-656E7F9817CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5523217-5311-4230-B7B1-656E7F9817CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F7B3497A-49F5-4A20-80FD-83B0F1B8F1AB}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

View File

@ -0,0 +1,183 @@
namespace windows2go.switcher {
partial class FormMain {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.menuStripHelp = new System.Windows.Forms.ToolStripMenuItem();
this.menuStripItemHelp = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.menuStripItemAbout = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox = new System.Windows.Forms.GroupBox();
this.buttonSet = new System.Windows.Forms.Button();
this.labelState = new System.Windows.Forms.Label();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripRegValue = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelRegValue = new System.Windows.Forms.ToolStripStatusLabel();
this.menuStrip.SuspendLayout();
this.groupBox.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// menuStrip
//
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuStripHelp});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(487, 24);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "menuStrip1";
//
// menuStripHelp
//
this.menuStripHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuStripItemHelp,
this.toolStripSeparator1,
this.menuStripItemAbout});
this.menuStripHelp.Name = "menuStripHelp";
this.menuStripHelp.Size = new System.Drawing.Size(44, 20);
this.menuStripHelp.Text = "Help";
//
// menuStripItemHelp
//
this.menuStripItemHelp.Name = "menuStripItemHelp";
this.menuStripItemHelp.Size = new System.Drawing.Size(107, 22);
this.menuStripItemHelp.Text = "Help";
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(104, 6);
//
// menuStripItemAbout
//
this.menuStripItemAbout.Name = "menuStripItemAbout";
this.menuStripItemAbout.Size = new System.Drawing.Size(107, 22);
this.menuStripItemAbout.Text = "About";
//
// groupBox
//
this.groupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox.Controls.Add(this.buttonSet);
this.groupBox.Controls.Add(this.labelState);
this.groupBox.Location = new System.Drawing.Point(12, 27);
this.groupBox.Name = "groupBox";
this.groupBox.Size = new System.Drawing.Size(463, 173);
this.groupBox.TabIndex = 1;
this.groupBox.TabStop = false;
this.groupBox.Text = "Current state:";
//
// buttonSet
//
this.buttonSet.Enabled = false;
this.buttonSet.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.buttonSet.Location = new System.Drawing.Point(6, 124);
this.buttonSet.Name = "buttonSet";
this.buttonSet.Size = new System.Drawing.Size(451, 41);
this.buttonSet.TabIndex = 1;
this.buttonSet.Text = "Set Some State";
this.buttonSet.UseVisualStyleBackColor = true;
this.buttonSet.Click += new System.EventHandler(this.buttonSet_Click);
//
// labelState
//
this.labelState.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.labelState.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.labelState.ForeColor = System.Drawing.SystemColors.ControlText;
this.labelState.Location = new System.Drawing.Point(6, 16);
this.labelState.Name = "labelState";
this.labelState.Size = new System.Drawing.Size(451, 105);
this.labelState.TabIndex = 0;
this.labelState.Text = "state";
this.labelState.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripRegValue,
this.toolStripStatusLabelRegValue});
this.statusStrip1.Location = new System.Drawing.Point(0, 203);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(487, 22);
this.statusStrip1.TabIndex = 2;
this.statusStrip1.Text = "statusStrip";
//
// toolStripRegValue
//
this.toolStripRegValue.Image = global::windows2go.switcher.Properties.Resources.Icon8;
this.toolStripRegValue.Name = "toolStripRegValue";
this.toolStripRegValue.Size = new System.Drawing.Size(161, 17);
this.toolStripRegValue.Text = "PortableOperatingSystem:";
//
// toolStripStatusLabelRegValue
//
this.toolStripStatusLabelRegValue.Image = global::windows2go.switcher.Properties.Resources.cancel;
this.toolStripStatusLabelRegValue.Name = "toolStripStatusLabelRegValue";
this.toolStripStatusLabelRegValue.Size = new System.Drawing.Size(16, 17);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(487, 225);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.groupBox);
this.Controls.Add(this.menuStrip);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip;
this.MaximizeBox = false;
this.Name = "FormMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Windows2go Switcher";
this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.groupBox.ResumeLayout(false);
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip;
private System.Windows.Forms.ToolStripMenuItem menuStripHelp;
private System.Windows.Forms.ToolStripMenuItem menuStripItemHelp;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem menuStripItemAbout;
private System.Windows.Forms.GroupBox groupBox;
private System.Windows.Forms.Label labelState;
private System.Windows.Forms.Button buttonSet;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripRegValue;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelRegValue;
}
}

View File

@ -0,0 +1,201 @@
using Microsoft.Win32;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace windows2go.switcher {
public partial class FormMain : Form {
static RegistryKey BaseKey = Registry.LocalMachine;
static RegistryKey SYSTEMKey = BaseKey.OpenSubKey("SYSTEM");
static RegistryKey CurrentControlSetKey = SYSTEMKey.OpenSubKey("CurrentControlSet");
static RegistryKey ControlKey = CurrentControlSetKey.OpenSubKey("Control",true);
int CurrentStateCode; //-1 not exists, 0 normal, 1 portable, 2 wrond dword, 3 not a dword
public FormMain() {
InitializeComponent();
UACSecurity.AddShieldToButton(buttonSet);
if (UACSecurity.IsAdmin()) this.Text += " (Administrator)";
}
private void FormMain_Load(object sender, EventArgs e) {
try {
TryToGetValue();
} catch (Exception ex) {
MessageBox.Show("Error!" + Environment.NewLine + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void TryToGetValue() {
object PortableOperatingSystemValue = ControlKey.GetValue("PortableOperatingSystem");
if(PortableOperatingSystemValue != null) {
switch (ControlKey.GetValueKind("PortableOperatingSystem")) {
case RegistryValueKind.String:
case RegistryValueKind.ExpandString:
inBadTypeState();
break;
case RegistryValueKind.Binary:
inBadTypeState();
break;
case RegistryValueKind.DWord:
//if "PortableOperatingSystem" and it;s value not normal. example = "PortableOperatingSystem=42"
if ((PortableOperatingSystemValue.ToString() != "0") && (PortableOperatingSystemValue.ToString() != "1")) {
inWrongValueState();
} else if (PortableOperatingSystemValue.ToString() == "0") {
inNormalValueState();
} else if(PortableOperatingSystemValue.ToString() == "1") {
inPortableValueState();
}
break;
case RegistryValueKind.QWord:
inBadTypeState();
break;
case RegistryValueKind.MultiString:
foreach (string s in (string[])PortableOperatingSystemValue) {
inBadTypeState();
}
Console.WriteLine();
break;
default:
inBadTypeState();
break;
}
} else {
inNotExistsState();
}
}
#region states
private void inNotExistsState() {
buttonSet.Enabled = true;
buttonSet.Text = @"Forced set to normal?";
labelState.Text = "\"PortableOperatingSystem\" not found in registry." + Environment.NewLine +
"It's equals normal mode.";
labelState.ForeColor = Color.OrangeRed;
toolStripStatusLabelRegValue.Image = Properties.Resources.cancel;
toolStripStatusLabelRegValue.Text = "";
CurrentStateCode = -1;
}
private void inNormalValueState() {
buttonSet.Enabled = true;
buttonSet.Text = @"Set Portable";
labelState.Text = "System running in normal mode." + Environment.NewLine +
"You able to switch to another.";
labelState.ForeColor = Color.LimeGreen;
toolStripStatusLabelRegValue.Image = null;
toolStripStatusLabelRegValue.Text = "0";
CurrentStateCode = 0;
}
private void inPortableValueState() {
buttonSet.Enabled = true;
buttonSet.Text = @"Set Normal";
labelState.Text = "System running in \"Windows To Go\" mode." + Environment.NewLine +
"You able to switch to another.";
labelState.ForeColor = Color.Crimson;
toolStripStatusLabelRegValue.Image = null;
toolStripStatusLabelRegValue.Text = "1";
CurrentStateCode = 1;
}
private void inWrongValueState() {
buttonSet.Enabled = true;
buttonSet.Text = @"Forced set to normal?";
labelState.Text = "DWORD \"PortableOperatingSystem\" have wrong value." + Environment.NewLine +
"It's strange but equals normal mode.";
labelState.ForeColor = Color.OrangeRed;
toolStripStatusLabelRegValue.Image = Properties.Resources.cancel;
toolStripStatusLabelRegValue.Text = "";
CurrentStateCode = 2;
}
private void inBadTypeState() {
buttonSet.Enabled = true;
buttonSet.Text = @"Forced set to normal?";
labelState.Text = "\"PortableOperatingSystem\" is not a DWORD." + Environment.NewLine +
"It's strange but equals normal mode.";
labelState.ForeColor = Color.OrangeRed;
toolStripStatusLabelRegValue.Image = Properties.Resources.cancel;
toolStripStatusLabelRegValue.Text = "";
CurrentStateCode = 3;
}
#endregion
#region set states
private void SetNormalState() {
ControlKey.SetValue("PortableOperatingSystem", 0, RegistryValueKind.DWord);
}
private void ForcedFixNormalState() {
ControlKey.DeleteValue("PortableOperatingSystem");
SetNormalState();
}
private void SetPortableState() {
ControlKey.SetValue("PortableOperatingSystem", 1, RegistryValueKind.DWord);
}
#endregion
private void buttonSet_Click(object sender, EventArgs e) {
switch (CurrentStateCode) {
//case when it not exists yet
case -1:
try {
SetNormalState();
MessageBox.Show("Succuess!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
} catch (Exception ex) {
MessageBox.Show("Error!" + Environment.NewLine + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
break;
//case when it in normal mode
case 0:
try {
SetPortableState();
MessageBox.Show("Succuess!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
} catch (Exception ex) {
MessageBox.Show("Error!" + Environment.NewLine + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
break;
//case when it in portable mode
case 1:
try {
SetNormalState();
MessageBox.Show("Succuess!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
} catch (Exception ex) {
MessageBox.Show("Error!" + Environment.NewLine + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
break;
//case when wrond dword value
case 2:
try {
SetNormalState();
MessageBox.Show("Succuess!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
} catch (Exception ex) {
MessageBox.Show("Error!" + Environment.NewLine + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
break;
//case when it is not an dwrond
case 3:
try {
ForcedFixNormalState();
MessageBox.Show("Succuess!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
} catch (Exception ex) {
MessageBox.Show("Error!" + Environment.NewLine + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
break;
}
try {
TryToGetValue();
} catch (Exception ex) {
MessageBox.Show("Error!" + Environment.NewLine + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
using System;
using System.Windows.Forms;
namespace windows2go.switcher {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}
}
}

View File

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("windows2go.switcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("windows2go.switcher")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d5523217-5311-4230-b7b1-656e7f9817ce")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,93 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace windows2go.switcher.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("windows2go.switcher.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap cancel {
get {
object obj = ResourceManager.GetObject("cancel", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Icon6 {
get {
object obj = ResourceManager.GetObject("Icon6", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Icon8 {
get {
object obj = ResourceManager.GetObject("Icon8", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Icon8" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icon8.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Icon6" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Icon6.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="cancel" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\cancel.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace windows2go.switcher.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

View File

@ -0,0 +1,56 @@
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Windows.Forms;
using System.Security.Principal;
namespace windows2go.switcher {
public static class UACSecurity {
[DllImport("user32")]
public static extern UInt32 SendMessage(IntPtr hWnd, UInt32 msg, UInt32 wParam, UInt32 lParam);
internal const int BCM_FIRST = 0x1600;
internal const int BCM_SETSHIELD = (BCM_FIRST + 0x000C);
static internal bool IsVistaOrHigher() {
return Environment.OSVersion.Version.Major < 6;
}
/// <summary>
/// Checks if the process is elevated
/// </summary>
/// <returns>If is elevated</returns>
static internal bool IsAdmin() {
WindowsIdentity id = WindowsIdentity.GetCurrent();
WindowsPrincipal p = new WindowsPrincipal(id);
return p.IsInRole(WindowsBuiltInRole.Administrator);
}
/// <summary>
/// Add a shield icon to a button
/// </summary>
/// <param name="b">The button</param>
static internal void AddShieldToButton(Button b) {
b.FlatStyle = FlatStyle.System;
SendMessage(b.Handle, BCM_SETSHIELD, 0, 0xFFFFFFFF);
}
/// <summary>
/// Restart the current process with administrator credentials
/// </summary>
internal static void RestartElevated() {
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.FileName = Application.ExecutablePath;
startInfo.Verb = "runas";
try {
Process p = Process.Start(startInfo);
} catch (System.ComponentModel.Win32Exception ex) {
return; //If cancelled, do nothing
}
Application.Exit();
}
}
}

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D5523217-5311-4230-B7B1-656E7F9817CE}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>windows2go.switcher</RootNamespace>
<AssemblyName>windows2go.switcher</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>windows.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FormMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain.Designer.cs">
<DependentUpon>FormMain.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UACSecurity.cs" />
<EmbeddedResource Include="FormMain.resx">
<DependentUpon>FormMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Icon6.png" />
<None Include="Resources\Icon8.png" />
<None Include="Resources\cancel.png" />
<Content Include="windows.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>