diff --git a/WoL/Waker/MainForm.Designer.cs b/WoL/Waker/MainForm.Designer.cs index 8d2bb4b..fca6ab0 100644 --- a/WoL/Waker/MainForm.Designer.cs +++ b/WoL/Waker/MainForm.Designer.cs @@ -42,6 +42,7 @@ namespace Waker this.label4 = new System.Windows.Forms.Label(); this.PingStatusPanel = new System.Windows.Forms.Panel(); this.pingTimer = new System.Windows.Forms.Timer(this.components); + this.RECButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // AddressTextBox @@ -80,7 +81,7 @@ namespace Waker // this.WakeButton.Location = new System.Drawing.Point(271, 12); this.WakeButton.Name = "WakeButton"; - this.WakeButton.Size = new System.Drawing.Size(102, 112); + this.WakeButton.Size = new System.Drawing.Size(102, 83); this.WakeButton.TabIndex = 4; this.WakeButton.Text = "WoL"; this.WakeButton.UseVisualStyleBackColor = true; @@ -134,12 +135,23 @@ namespace Waker this.pingTimer.Interval = 5000; this.pingTimer.Tick += new System.EventHandler(this.pingTimer_Tick); // + // RECButton + // + this.RECButton.Location = new System.Drawing.Point(271, 101); + this.RECButton.Name = "RECButton"; + this.RECButton.Size = new System.Drawing.Size(102, 23); + this.RECButton.TabIndex = 5; + this.RECButton.Text = "RD Client"; + this.RECButton.UseVisualStyleBackColor = true; + this.RECButton.Click += new System.EventHandler(this.RECButton_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.White; this.ClientSize = new System.Drawing.Size(383, 134); + this.Controls.Add(this.RECButton); this.Controls.Add(this.PingStatusPanel); this.Controls.Add(this.label4); this.Controls.Add(this.label3); @@ -174,6 +186,7 @@ namespace Waker private System.Windows.Forms.Label label4; private System.Windows.Forms.Panel PingStatusPanel; private System.Windows.Forms.Timer pingTimer; + private System.Windows.Forms.Button RECButton; } } diff --git a/WoL/Waker/MainForm.cs b/WoL/Waker/MainForm.cs index 8a8692f..9db2ee3 100644 --- a/WoL/Waker/MainForm.cs +++ b/WoL/Waker/MainForm.cs @@ -10,6 +10,10 @@ using System.Windows.Forms; using WakeOnLan; using System.Configuration; using System.Threading; +using System.Reflection; +using System.Security.Principal; +using System.Diagnostics; +using System.IO; namespace Waker { @@ -226,5 +230,14 @@ namespace Waker else PingStatusPanel.BackColor = PING_FAIL; } + + private void RECButton_Click(object sender, EventArgs e) + { + string path = @"C:\Windows\System32\mstsc.exe"; + if (!File.Exists(path)) + return; + + Process.Start(path); + } } } diff --git a/WoL/Waker/Waker.csproj b/WoL/Waker/Waker.csproj index fb86836..da69189 100644 --- a/WoL/Waker/Waker.csproj +++ b/WoL/Waker/Waker.csproj @@ -11,6 +11,7 @@ 1.0.0.1 Designcontest-Ecommerce-Business-Idea.ico + app.manifest diff --git a/WoL/Waker/app.manifest b/WoL/Waker/app.manifest new file mode 100644 index 0000000..8725c92 --- /dev/null +++ b/WoL/Waker/app.manifest @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WoL/WoL/Utils.cs b/WoL/WoL/Utils.cs index 82fde55..9db7841 100644 --- a/WoL/WoL/Utils.cs +++ b/WoL/WoL/Utils.cs @@ -1,13 +1,24 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.IO; using System.Net; +using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; +using System.Security.Principal; namespace WakeOnLan { - class Utils + public class Utils { + [DllImport("kernel32.dll", SetLastError = true)] + static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); + + [DllImport("kernel32.dll", SetLastError = true)] + static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr); + + public static IPAddress GetIpAddress(string ip) { Regex regex = new Regex(@"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$"); @@ -20,5 +31,29 @@ namespace WakeOnLan return hostEntry.AddressList[0]; } + + public static void SysTest() + { + IntPtr wow64Value = IntPtr.Zero; + + File.Create(@"c:\windows\system32\test"); + Debug.WriteLine("Default System Directory : {0}", File.Exists(@"c:\windows\system32\test")); + + //Disable Redirection + Wow64DisableWow64FsRedirection(ref wow64Value); + Debug.WriteLine("Wow64Redirection Disable : {0}", File.Exists(@"c:\windows\system32\test")); + + //Enable Redirection + Wow64RevertWow64FsRedirection(wow64Value); + Debug.WriteLine("Wow64Redirection Enable : {0}", File.Exists(@"c:\windows\system32\test")); + } + + public static bool IsRunningAsAdmin() + { + WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent(); + WindowsPrincipal windowsPrincipal = new WindowsPrincipal(windowsIdentity); + + return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator); + } } } diff --git a/WoL/WoL/WakeOnLan.csproj b/WoL/WoL/WakeOnLan.csproj index cb63190..85f1299 100644 --- a/WoL/WoL/WakeOnLan.csproj +++ b/WoL/WoL/WakeOnLan.csproj @@ -4,4 +4,8 @@ netcoreapp3.1 + + + +