diff --git a/.vs/CMWTAT_DIGITAL/DesignTimeBuild/.dtbcache b/.vs/CMWTAT_DIGITAL/DesignTimeBuild/.dtbcache
new file mode 100644
index 0000000..be35deb
Binary files /dev/null and b/.vs/CMWTAT_DIGITAL/DesignTimeBuild/.dtbcache differ
diff --git a/.vs/CMWTAT_DIGITAL/v15/.suo b/.vs/CMWTAT_DIGITAL/v15/.suo
index 3b036cf..b67cdc6 100644
Binary files a/.vs/CMWTAT_DIGITAL/v15/.suo and b/.vs/CMWTAT_DIGITAL/v15/.suo differ
diff --git a/.vs/CMWTAT_DIGITAL/v15/Server/sqlite3/storage.ide b/.vs/CMWTAT_DIGITAL/v15/Server/sqlite3/storage.ide
index ef602ed..2ec5ff7 100644
Binary files a/.vs/CMWTAT_DIGITAL/v15/Server/sqlite3/storage.ide and b/.vs/CMWTAT_DIGITAL/v15/Server/sqlite3/storage.ide differ
diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config
new file mode 100644
index 0000000..5441f24
--- /dev/null
+++ b/.vs/config/applicationhost.config
@@ -0,0 +1,1022 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CMWTAT_DIGITAL/App.xaml b/CMWTAT_DIGITAL/App.xaml
index 904078b..996f138 100644
--- a/CMWTAT_DIGITAL/App.xaml
+++ b/CMWTAT_DIGITAL/App.xaml
@@ -2,7 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CMWTAT_KMS"
- StartupUri="MainWindow.xaml">
+ StartupUri="MainWindow.xaml"
+ >
diff --git a/CMWTAT_DIGITAL/App.xaml.cs b/CMWTAT_DIGITAL/App.xaml.cs
index 374ac42..ac47f66 100644
--- a/CMWTAT_DIGITAL/App.xaml.cs
+++ b/CMWTAT_DIGITAL/App.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using CMWTAT_DIGITAL;
+using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
diff --git a/CMWTAT_DIGITAL/CMWTAT.ico b/CMWTAT_DIGITAL/CMWTAT.ico
new file mode 100644
index 0000000..42f687a
Binary files /dev/null and b/CMWTAT_DIGITAL/CMWTAT.ico differ
diff --git a/CMWTAT_DIGITAL/CMWTAT.png b/CMWTAT_DIGITAL/CMWTAT.png
new file mode 100644
index 0000000..e0ebb76
Binary files /dev/null and b/CMWTAT_DIGITAL/CMWTAT.png differ
diff --git a/CMWTAT_DIGITAL/CMWTAT_DIGITAL.csproj b/CMWTAT_DIGITAL/CMWTAT_DIGITAL.csproj
index 134b446..dc66538 100644
--- a/CMWTAT_DIGITAL/CMWTAT_DIGITAL.csproj
+++ b/CMWTAT_DIGITAL/CMWTAT_DIGITAL.csproj
@@ -2,6 +2,7 @@
+ 10.0.10240.0
Debug
AnyCPU
{961DE925-B82C-4515-8FBD-6805E36D1212}
@@ -13,6 +14,21 @@
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
AnyCPU
@@ -41,18 +57,28 @@
CMWTAT.ico
+
+ CMWTAT_DIGITAL.Program
+
..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll
+ False
..\packages\MaterialDesignThemes.2.4.0.1044\lib\net45\MaterialDesignThemes.Wpf.dll
+ False
..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
+ False
+
+
+
+
@@ -61,6 +87,9 @@
4.0
+
+
+
@@ -92,6 +121,7 @@
+
Code
@@ -122,5 +152,29 @@
+
+
+
+
+
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CMWTAT_DIGITAL/CMWTAT_DIGITAL.csproj.user b/CMWTAT_DIGITAL/CMWTAT_DIGITAL.csproj.user
new file mode 100644
index 0000000..eb58e18
--- /dev/null
+++ b/CMWTAT_DIGITAL/CMWTAT_DIGITAL.csproj.user
@@ -0,0 +1,20 @@
+
+
+
+ --hide -a
+
+
+ publish\
+
+
+
+
+
+ zh-CN
+ false
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CMWTAT_DIGITAL/MainWindow.xaml b/CMWTAT_DIGITAL/MainWindow.xaml
index 1b71d6a..cfc7922 100644
--- a/CMWTAT_DIGITAL/MainWindow.xaml
+++ b/CMWTAT_DIGITAL/MainWindow.xaml
@@ -17,6 +17,8 @@
FontFamily="{DynamicResource MaterialDesignFont}"
ResizeMode="NoResize"
d:DataContext="{d:DesignInstance domain:ViewModel, d:IsDesignTimeCreatable=False}"
+ Icon="CMWTAT.ico"
+ Closing="Window_Closing"
>
@@ -117,6 +119,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CMWTAT_DIGITAL/MainWindow.xaml.cs b/CMWTAT_DIGITAL/MainWindow.xaml.cs
index f19ea8c..835e21c 100644
--- a/CMWTAT_DIGITAL/MainWindow.xaml.cs
+++ b/CMWTAT_DIGITAL/MainWindow.xaml.cs
@@ -21,6 +21,7 @@ using System.Threading;
using Microsoft.Win32;
using CMWTAT_DIGITAL.Domain;
using System.Text.RegularExpressions;
+using System.Windows.Forms;
namespace CMWTAT_DIGITAL
{
@@ -31,18 +32,169 @@ namespace CMWTAT_DIGITAL
{
[DllImport("Kernel32.dll")]
private static extern bool Wow64EnableWow64FsRedirection(bool Wow64FsEnableRedirection);//重定向
+
public struct Frequency
{
public int ID { get; set; }
public string DisplayOS { get; set; }
}
+
+ string tempfile = System.IO.Path.GetTempPath() + @"CMWTAT_DIGITAL\";
+
+ public void DelectTempFile()
+ {
+ //string tempfile = System.IO.Path.GetTempPath() + @"CMWTAT_DIGITAL\";
+ if (Directory.Exists(tempfile))
+ {
+ try
+ {
+ //DirectoryInfo dir = new DirectoryInfo(srcPath);
+ //FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
+ //foreach (FileSystemInfo i in fileinfo)
+ //{
+ // if (i is DirectoryInfo) //判断是否文件夹
+ // {
+ // DirectoryInfo subdir = new DirectoryInfo(i.FullName);
+ // subdir.Delete(true); //删除子目录和文件
+ // }
+ // else
+ // {
+ // File.Delete(i.FullName); //删除指定文件
+ // }
+ //}
+ FileAttributes attr = File.GetAttributes(tempfile);
+ if (attr == FileAttributes.Directory)
+ {
+ Directory.Delete(tempfile, true);
+ }
+ else
+ {
+ File.Delete(tempfile);
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("DelectTempFile:" + e.Message);
+ }
+ }
+ }
+
+ public void ExportTempFile()
+ {
+ //string tempfile = System.IO.Path.GetTempPath() + @"CMWTAT_DIGITAL\";
+
+ //if (tempfile.EndsWith(@"\"))
+ //{
+ // tempfile = tempfile.Remove(tempfile.Length - 1, 1);
+ //}
+
+ if (!Directory.Exists(tempfile))
+ {
+ Directory.CreateDirectory(tempfile);
+ }
+
+ byte[] temp;
+ System.IO.FileStream fileStream;
+
+ temp = CMWTAT_DIGITAL.Properties.Resources.gatherosstate;
+ fileStream = new System.IO.FileStream(tempfile + "gatherosstate" + ".exe", System.IO.FileMode.CreateNew);
+ fileStream.Write(temp, 0, (int)(temp.Length));
+ fileStream.Close();
+
+ temp = CMWTAT_DIGITAL.Properties.Resources.slc;
+ fileStream = new System.IO.FileStream(tempfile + "slc" + ".dll", System.IO.FileMode.CreateNew);
+ fileStream.Write(temp, 0, (int)(temp.Length));
+ fileStream.Close();
+
+ temp = CMWTAT_DIGITAL.Properties.Resources.slmgr;
+ fileStream = new System.IO.FileStream(tempfile + "slmgr" + ".vbs", System.IO.FileMode.CreateNew);
+ fileStream.Write(temp, 0, (int)(temp.Length));
+ fileStream.Close();
+ }
+
+ bool autoact = false;
+ bool hiderun = false;
+ bool expact = false;
+ bool showhelp = false;
+
//public string SystemEdition = OSVersionInfo.Name + " " + OSVersionInfo.Edition;
public string SystemEdition = OSVersionInfo.Edition;
+
+ NotifyIcon notifyIcon;
+
public MainWindow()
{
+ autoact = Program.autoact;
+ hiderun = Program.hiderun;
+ expact = Program.expact;
+ showhelp = Program.showhelp;
+
+ //MessageBox.Show("A:" + autoact.ToString() + ";H:" + hiderun.ToString());
+
InitializeComponent();
+ if (showhelp == true)
+ {
+ DialogHelp.IsOpen = true;
+ }
+
+ notifyIcon = new System.Windows.Forms.NotifyIcon();
+ notifyIcon.Text = "CloudMoe Windows 10 Activation Toolkit V2";
+ notifyIcon.Icon = ((System.Drawing.Icon)(CMWTAT_DIGITAL.Properties.Resources.CMWTAT_ICON));
+
+ if (hiderun == true && autoact == true)
+ {
+ this.Hide();
+ //notifyIcon.BalloonTipText = "The app has been minimised. Click the tray icon to show.";
+ //notifyIcon.BalloonTipTitle = "The App";
+
+ //notifyIcon.Icon = new System.Drawing.Icon("TheAppIcon.ico");
+
+ //notifyIcon.Click += new EventHandler(notifyIcon_Click);
+
+ notifyIcon.Visible = true;
+
+ //打开菜单项
+ //System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("Open");
+ //open.Click += new EventHandler((o, e) =>
+ //{
+ // this.Show();
+ //});
+
+ //退出菜单项
+ System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("Exit");
+ exit.Click += new EventHandler(Exit_Button_Click);
+
+ //关联托盘控件
+ //System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { open, exit };
+
+ System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { exit };
+
+ notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen);
+
+ //this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler((o, e) =>
+ //{
+ // if (e.Button == MouseButtons.Left) this.Show();
+ //});
+
+ int tipShowMilliseconds = 0;
+ string tipTitle = "CloudMoe Windows 10 Activation Toolkit V2";
+ string tipContent = "Running.";
+ ToolTipIcon tipType = ToolTipIcon.None;
+ notifyIcon.ShowBalloonTip(tipShowMilliseconds, tipTitle, tipContent, tipType);
+
+ //notifyIcon.BalloonTipClicked += new EventHandler((o, e) =>
+ //{
+ // //System.Windows.MessageBox.Show(System.Windows.Forms.Control.MouseButtons.ToString());
+ // if (System.Windows.Forms.Control.MouseButtons == MouseButtons.None) //左键返回不是Right是None
+ // {
+ // System.Windows.MessageBox.Show("Hello");
+ // };
+ //});
+ }
+
+ //初始化动态表单数据绑定
DataContext = new ViewModel();
this.DialogHostGrid.Visibility = Visibility.Visible;
@@ -63,7 +215,9 @@ namespace CMWTAT_DIGITAL
//SystemEditionText.Text = SystemEdition;
Thread loadthread = new Thread(LoadOSList);
loadthread.Start();
+
}
+
JArray ositems;
int now_os_index = 0;
string checked_os = "unknow";
@@ -79,6 +233,9 @@ namespace CMWTAT_DIGITAL
}
private void LoadOSList()
{
+
+ int is_selected = 0; //是否已经自动选择,0未选择,1普通模式,2实验模式
+
actbtn.Dispatcher.Invoke(new Action(() =>
{
DialogWait.IsOpen = true;
@@ -90,24 +247,32 @@ namespace CMWTAT_DIGITAL
List list = new List();
Frequency freq = new Frequency();
ositems = (JArray)jsonobj["OS"];
+
for (int i = 0; i < ositems.Count(); i++)
{
freq.ID = i;
freq.DisplayOS = jsonobj["OS"][i].ToString();
- if (jsonobj["OS"][i].ToString() == SystemEdition)
- {
- now_os_index = i;
- checked_os = SystemEdition;
- }
- if (jsonobj["OS"][i].ToString() == SystemEdition + OSVersionInfo.BuildVersion)
+
+ //按照优先级判断,如果已经自动选择则忽略新的
+ if (String.Equals(jsonobj["OS"][i].ToString(), SystemEdition + OSVersionInfo.BuildVersion, StringComparison.CurrentCultureIgnoreCase) && is_selected == 0)//jsonobj["OS"][i].ToString() == SystemEdition + OSVersionInfo.BuildVersion
{
now_os_index = i;
checked_os = SystemEdition + OSVersionInfo.BuildVersion;
+ is_selected = 1;
}
- if (jsonobj["OS"][i].ToString() == "(Experimental) " + SystemEdition)
+
+ if (String.Equals(jsonobj["OS"][i].ToString(), SystemEdition, StringComparison.CurrentCultureIgnoreCase) && is_selected == 0)//jsonobj["OS"][i].ToString() == SystemEdition
+ {
+ now_os_index = i;
+ checked_os = SystemEdition;
+ is_selected = 1;
+ }
+
+ if (String.Equals(jsonobj["OS"][i].ToString(), "(Experimental) " + SystemEdition, StringComparison.CurrentCultureIgnoreCase) && is_selected == 0)//旧的方法:jsonobj["OS"][i].ToString() == "(Experimental) " + SystemEdition,新方法忽略大小写并提升效率
{
now_os_index = i;
checked_os = "(Experimental) " + SystemEdition;
+ is_selected = 2;
}
list.Add(freq);
}
@@ -116,11 +281,18 @@ namespace CMWTAT_DIGITAL
{
this.SystemEditionText.ItemsSource = list;//控件的ID
- if (checked_os == "unknow")
+ if (is_selected == 0)//没有匹配
{
this.SystemEditionText.SelectedIndex = 0;
this.DialogWithOKToCloseDialogTitle.Text = "Attention";
- this.DialogWithOKToCloseDialogText.Text = "Unable to correctly identify your operating system, may be not be supported.\r\n(System edition: " + SystemEdition + OSVersionInfo.BuildVersion + ")";
+ this.DialogWithOKToCloseDialogText.Text = "Unable to correctly identify your operating system edition, may be not be supported.\r\n(System edition: " + SystemEdition + OSVersionInfo.BuildVersion + ")";
+ this.DialogWithOKToCloseDialog.IsOpen = true;
+ }
+ else if (is_selected == 2)//只找到实验性
+ {
+ this.SystemEditionText.SelectedIndex = 0;
+ this.DialogWithOKToCloseDialogTitle.Text = "Attention";
+ this.DialogWithOKToCloseDialogText.Text = "Only find experimental options that can be used with this operating system edition, little hope of activation success.\r\n(System edition: " + SystemEdition + OSVersionInfo.BuildVersion + ")";
this.DialogWithOKToCloseDialog.IsOpen = true;
}
else
@@ -130,19 +302,78 @@ namespace CMWTAT_DIGITAL
}));
//this.SystemEditionText.SelectedIndex = now_os_index;
+
+ actbtn.Dispatcher.Invoke(new Action(() =>
+ {
+ DialogWait.IsOpen = false;
+ }));
+
+ if (autoact == true)//自动激活
+ {
+ Thread actthread = new Thread(RunAct);
+ switch (is_selected)
+ {
+ case 1: //正常
+ actthread.Start();
+ break;
+ case 2: //实验性
+ if (expact == true)
+ {
+ actbtn.Dispatcher.Invoke(new Action(() =>
+ {
+ DialogWithOKToCloseDialog.IsOpen = false;
+ }));
+ actthread.Start();
+ }
+ else
+ {
+ if (hiderun == true)
+ {
+ int tipShowMilliseconds = 0;
+ string tipTitle = "CloudMoe Windows 10 Activation Toolkit V2";
+ string tipContent = "Your system edition may not be supported, program will exit. you can try add --expact or -e to startup.";
+ ToolTipIcon tipType = ToolTipIcon.None;
+ notifyIcon.ShowBalloonTip(tipShowMilliseconds, tipTitle, tipContent, tipType);
+ Exit_Button_Click(null, null);//退出
+ }
+ }
+ break;
+ default:
+ if (hiderun == true)
+ {
+ int tipShowMilliseconds = 0;
+ string tipTitle = "CloudMoe Windows 10 Activation Toolkit V2";
+ string tipContent = "Your system edition may not be supported, program will exit.";
+ ToolTipIcon tipType = ToolTipIcon.None;
+ notifyIcon.ShowBalloonTip(tipShowMilliseconds, tipTitle, tipContent, tipType);
+ Exit_Button_Click(null, null);//退出
+ }
+ break;
+ }
+ }
}
catch
{
+ actbtn.Dispatcher.Invoke(new Action(() =>
+ {
+ DialogWait.IsOpen = false;
+ }));
+
actbtn.Dispatcher.Invoke(new Action(() =>
{
DialogWithExit.IsOpen = true;
}));
- }
- actbtn.Dispatcher.Invoke(new Action(() =>
- {
- DialogWait.IsOpen = false;
- }));
+ if (hiderun == true && autoact == true)
+ {
+ int tipShowMilliseconds = 0;
+ string tipTitle = "CloudMoe Windows 10 Activation Toolkit V2";
+ string tipContent = "Unable to connect to server, program will exit.";
+ ToolTipIcon tipType = ToolTipIcon.None;
+ notifyIcon.ShowBalloonTip(tipShowMilliseconds, tipTitle, tipContent, tipType);
+ Exit_Button_Click(null, null);//退出
+ }
+ }
}
private void Activate_Button_Click(object sender, RoutedEventArgs e)
{
@@ -181,13 +412,17 @@ namespace CMWTAT_DIGITAL
return strHTML;
}
- private void Exit_Button_Click(object sender, RoutedEventArgs e)
+ private void Exit_Button_Click(object sender, EventArgs e)
{
- Application.Current.Shutdown();
+ DelectTempFile();
+ notifyIcon.Visible = false;
+ System.Windows.Application.Current.Shutdown();
}
private void RunInstall()
{
+ ExportTempFile();
+ //释放文件
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.DialogActProg.IsOpen = true;
@@ -203,7 +438,11 @@ namespace CMWTAT_DIGITAL
string system = "";
string slmgr = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) + "\\slmgr.vbs";
- string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";
+
+ string slmgr_self = tempfile + "slmgr.vbs";
+
+ //旧的位置
+ //string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";
string changepk = Environment.SystemDirectory + "\\changepk.exe";
@@ -283,8 +522,8 @@ namespace CMWTAT_DIGITAL
code = "-1";
msg = "无法卸载旧密钥 :(\nCannot to uninstall old key. :(";
}
- //string runend = RunCScript(slmgr_self, "-upk").Trim();
- EndLine:;
+ //string runend = RunCScript(slmgr_self, "-upk").Trim();
+ EndLine:;
if (code != "200")
{
actbtn.Dispatcher.Invoke(new Action(() =>
@@ -309,14 +548,34 @@ namespace CMWTAT_DIGITAL
}));
//MessageBox.Show("Congratulation!");
}
+ DelectTempFile();
+ //清理文件
+ }
+
+ private void ShowBallSameDig()
+ {
+ actbtn.Dispatcher.Invoke(new Action(() =>
+ {
+ if (hiderun == true && autoact == true)
+ {
+ int tipShowMilliseconds = 0;
+ string tipTitle = "CloudMoe Windows 10 Activation Toolkit V2";
+ string tipContent = this.activatingtext.Text;
+ ToolTipIcon tipType = ToolTipIcon.None;
+ notifyIcon.ShowBalloonTip(tipShowMilliseconds, tipTitle, tipContent, tipType);
+ }
+ }));
}
private void RunAct()
{
+ ExportTempFile();
+ //释放文件
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.DialogActProg.IsOpen = true;
this.activatingtext.Text = "Activating";
+ ShowBallSameDig();
}));
Wow64EnableWow64FsRedirection(false);//关闭文件重定向
@@ -329,7 +588,11 @@ namespace CMWTAT_DIGITAL
string mode = "1"; //1:普通(SYS、SKU、KEY完全);2.需要获取SKU(SYS、KEY);3.手动输入KEY
string slmgr = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86) + "\\slmgr.vbs";
- string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";
+
+ string slmgr_self = tempfile + "slmgr.vbs";
+
+ //旧的位置
+ //string slmgr_self = System.AppDomain.CurrentDomain.BaseDirectory + "slmgr.vbs";
string changepk = Environment.SystemDirectory + "\\changepk.exe";
@@ -344,6 +607,7 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Getting Key";
+ ShowBallSameDig();
}));
//获取密钥和SKU
@@ -386,6 +650,7 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Uninstalling old Key";
+ ShowBallSameDig();
}));
//卸载
@@ -402,6 +667,7 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Getting edition code (Experimental)";
+ ShowBallSameDig();
}));
//安装转换密钥
@@ -417,6 +683,7 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Uninstalling old Key (Experimental)";
+ ShowBallSameDig();
}));
runend = RunCScript(slmgr_self, "-upk").Trim();
@@ -426,6 +693,7 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Prepare for the next step (Experimental)";
+ ShowBallSameDig();
}));
}
}
@@ -450,6 +718,7 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Writing feature of old Windows version";
+ ShowBallSameDig();
}));
RunCMD(@"reg add ""HKLM\SYSTEM\Tokens"" /v ""Channel"" /t REG_SZ /d ""Retail"" /f");
@@ -460,6 +729,7 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Installing Key";
+ ShowBallSameDig();
}));
//安装数字权利升级密钥
@@ -472,21 +742,26 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Getting free upgrade permissions";
+ ShowBallSameDig();
}));
- RunCMD(System.AppDomain.CurrentDomain.BaseDirectory + "gatherosstate.exe");
+ RunCMD(tempfile + "gatherosstate.exe");
- for (int i = 0; i < 3 || !File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "GenuineTicket.xml"); i++)
+ //旧的位置
+ //RunCMD(System.AppDomain.CurrentDomain.BaseDirectory + "gatherosstate.exe"); tempfile
+
+ for (int i = 0; i < 3 || !File.Exists(tempfile + "GenuineTicket.xml"); i++) //旧的位置: for (int i = 0; i < 3 || !File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "GenuineTicket.xml"); i++)
{
Thread.Sleep(3000);
}
- if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "GenuineTicket.xml"))
+ if (File.Exists(tempfile + "GenuineTicket.xml")) //旧的位置: if (File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "GenuineTicket.xml"))
{
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Cleaning changes";
+ ShowBallSameDig();
}));
RunCMD(@"reg delete ""HKLM\SYSTEM\Tokens"" /f");
@@ -495,6 +770,7 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Getting digital license";
+ ShowBallSameDig();
}));
Wow64EnableWow64FsRedirection(false);//关闭文件重定向
@@ -503,6 +779,7 @@ namespace CMWTAT_DIGITAL
actbtn.Dispatcher.Invoke(new Action(() =>
{
this.activatingtext.Text = "Activating";
+ ShowBallSameDig();
}));
runend = RunCScript(slmgr_self, "-ato").Trim();
@@ -533,8 +810,8 @@ namespace CMWTAT_DIGITAL
code = "-1";
msg = "无法卸载旧密钥 :(\nCannot to uninstall old key. :(";
}
- //string runend = RunCScript(slmgr_self, "-upk").Trim();
- EndLine:;
+ //string runend = RunCScript(slmgr_self, "-upk").Trim();
+ EndLine:;
if (code != "200")
{
actbtn.Dispatcher.Invoke(new Action(() =>
@@ -544,6 +821,15 @@ namespace CMWTAT_DIGITAL
this.DialogWithOKToCloseDialog.IsOpen = true;
this.DialogWithOKToCloseDialogTitle.Text = "Error";
this.DialogWithOKToCloseDialogText.Text = msg + "\r\nCode:" + code;
+ if (hiderun == true && autoact == true)
+ {
+ int tipShowMilliseconds = 0;
+ string tipTitle = "CloudMoe Windows 10 Activation Toolkit V2";
+ string tipContent = msg;
+ ToolTipIcon tipType = ToolTipIcon.None;
+ notifyIcon.ShowBalloonTip(tipShowMilliseconds, tipTitle, tipContent, tipType);
+ Exit_Button_Click(null, null);
+ }
}));
//MessageBox.Show(msg + "\r\nCode:" + code);
}
@@ -556,9 +842,20 @@ namespace CMWTAT_DIGITAL
this.DialogWithOKToCloseDialogDonate.IsOpen = true;
this.DialogWithOKToCloseDialogDonateTitle.Text = "Complete";
this.DialogWithOKToCloseDialogDonateText.Text = "\nCongratulation! \n\nWindows 10 has been successful activated.\n";
+ if (hiderun == true && autoact == true)
+ {
+ int tipShowMilliseconds = 0;
+ string tipTitle = "CloudMoe Windows 10 Activation Toolkit V2";
+ string tipContent = "Congratulation!\nWindows 10 has been successful activated.";
+ ToolTipIcon tipType = ToolTipIcon.None;
+ notifyIcon.ShowBalloonTip(tipShowMilliseconds, tipTitle, tipContent, tipType);
+ Exit_Button_Click(null, null);
+ }
}));
//MessageBox.Show("Congratulation!");
}
+ DelectTempFile();
+ //清理文件
}
private void RunCMD(string var)
@@ -582,7 +879,7 @@ namespace CMWTAT_DIGITAL
public static string RunCScript(string path, string var = "")
{
Wow64EnableWow64FsRedirection(false);//关闭文件重定向
- //执行命令行函数
+ //执行命令行函数
try
{
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
@@ -610,7 +907,7 @@ namespace CMWTAT_DIGITAL
public static string GetSKU()
{
Wow64EnableWow64FsRedirection(false);//关闭文件重定向
- //执行命令行函数
+ //执行命令行函数
try
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
@@ -673,5 +970,11 @@ namespace CMWTAT_DIGITAL
SystemEditionTextInput.Visibility = Visibility.Visible;
is_auto = false;
}
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ DelectTempFile();
+ notifyIcon.Visible = false;
+ }
}
}
diff --git a/CMWTAT_DIGITAL/Program.cs b/CMWTAT_DIGITAL/Program.cs
new file mode 100644
index 0000000..35778b5
--- /dev/null
+++ b/CMWTAT_DIGITAL/Program.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace CMWTAT_DIGITAL
+{
+ public static class Program
+ {
+
+ public static bool autoact = false;
+ public static bool hiderun = false;
+ public static bool expact = false;
+ public static bool showhelp = false;
+
+ ///
+ /// Application Entry Point.
+ ///
+ [System.STAThreadAttribute()]
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
+
+ public static void Main(string[] startup_args)
+ {
+ //添加程序集解析事件
+ AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
+ {
+ String resourceName = "CMWTAT_DIGITAL.Res." +
+
+ new AssemblyName(args.Name).Name + ".dll";
+
+ using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
+ {
+ Byte[] assemblyData = new Byte[stream.Length];
+
+ stream.Read(assemblyData, 0, assemblyData.Length);
+
+ return Assembly.Load(assemblyData);
+ }
+ };
+
+ //if (startup_args.Length == 0)
+ //{
+ // //MessageBox.Show("ARGS NULL");
+ // //Console.WriteLine("CMWTAT Digital Edition V2");
+ // //Console.WriteLine("This application can use console args.");
+ //}
+ foreach (string arg in startup_args)
+ {
+ Console.WriteLine("arg: " + arg);
+ if (arg == "-a" || arg == "--auto")
+ {
+ Console.WriteLine("AUTO: True");
+ autoact = true;
+ }
+ if (arg == "-h" || arg == "--hide")
+ {
+ Console.WriteLine("HIDE: True");
+ hiderun = true;
+ }
+ if (arg == "-e" || arg == "--expact")
+ {
+ Console.WriteLine("EXPACT: True");
+ expact = true;
+ }
+ if (arg == "-?" || arg == "--help")
+ {
+ Console.WriteLine("EXPACT: True");
+ showhelp = true;
+ }
+ }
+
+ CMWTAT_DIGITAL.App app = new CMWTAT_DIGITAL.App();//WPF项目的Application实例,用来启动WPF项目的
+ app.InitializeComponent();
+ app.Run();
+ }
+ }
+}
diff --git a/CMWTAT_DIGITAL/Properties/AssemblyInfo.cs b/CMWTAT_DIGITAL/Properties/AssemblyInfo.cs
index 84c3213..7e8aa51 100644
--- a/CMWTAT_DIGITAL/Properties/AssemblyInfo.cs
+++ b/CMWTAT_DIGITAL/Properties/AssemblyInfo.cs
@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CloudMoe Network")]
[assembly: AssemblyProduct("CMWTAT Digital Edition V2")]
-[assembly: AssemblyCopyright("Copyright © CloudMoe Saltfish Studio 2017")]
+[assembly: AssemblyCopyright("Copyright © CloudMoe Saltfish Studio 2018")]
[assembly: AssemblyTrademark("CloudMoe Saltfish Studio")]
[assembly: AssemblyCulture("")]
@@ -51,5 +51,5 @@ using System.Windows;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.1.0.0")]
-[assembly: AssemblyFileVersion("2.1.0.0")]
+[assembly: AssemblyVersion("2.2.0.1")]
+[assembly: AssemblyFileVersion("2.2.0.1")]
diff --git a/CMWTAT_DIGITAL/Properties/Resources.Designer.cs b/CMWTAT_DIGITAL/Properties/Resources.Designer.cs
index 4db105a..4323442 100644
--- a/CMWTAT_DIGITAL/Properties/Resources.Designer.cs
+++ b/CMWTAT_DIGITAL/Properties/Resources.Designer.cs
@@ -59,5 +59,45 @@ namespace CMWTAT_DIGITAL.Properties {
resourceCulture = value;
}
}
+
+ ///
+ /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
+ ///
+ internal static System.Drawing.Icon CMWTAT_ICON {
+ get {
+ object obj = ResourceManager.GetObject("CMWTAT_ICON", resourceCulture);
+ return ((System.Drawing.Icon)(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Byte[] 类型的本地化资源。
+ ///
+ internal static byte[] gatherosstate {
+ get {
+ object obj = ResourceManager.GetObject("gatherosstate", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Byte[] 类型的本地化资源。
+ ///
+ internal static byte[] slc {
+ get {
+ object obj = ResourceManager.GetObject("slc", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Byte[] 类型的本地化资源。
+ ///
+ internal static byte[] slmgr {
+ get {
+ object obj = ResourceManager.GetObject("slmgr", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
}
}
diff --git a/CMWTAT_DIGITAL/Properties/Resources.resx b/CMWTAT_DIGITAL/Properties/Resources.resx
index af7dbeb..4d1c49b 100644
--- a/CMWTAT_DIGITAL/Properties/Resources.resx
+++ b/CMWTAT_DIGITAL/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
+
@@ -68,9 +69,10 @@
-
+
+
@@ -85,9 +87,10 @@
-
+
+
@@ -109,9 +112,22 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\CMWTAT.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Res\gatherosstate.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\Res\slc.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\Res\slmgr.vbs;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
\ No newline at end of file
diff --git a/CMWTAT_Digital_Release_2_2_0_1.exe b/CMWTAT_Digital_Release_2_2_0_1.exe
new file mode 100644
index 0000000..05c5699
Binary files /dev/null and b/CMWTAT_Digital_Release_2_2_0_1.exe differ
diff --git a/OSVersionInfoDLL/OSVersionInfoClass.cs b/OSVersionInfoDLL/OSVersionInfoClass.cs
deleted file mode 100644
index 92aa648..0000000
--- a/OSVersionInfoDLL/OSVersionInfoClass.cs
+++ /dev/null
@@ -1,1089 +0,0 @@
-using Microsoft.Win32;
-using System;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
-// http://www.codeproject.com/Articles/73000/Getting-Operating-System-Version-Info-Even-for-Win
-//https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
-
-//Thanks to Member 7861383, Scott Vickery for the Windows 8.1 update and workaround.
-//I have moved it to the beginning of the Name property, though...
-
-//Thakts to Brisingr Aerowing for help with the Windows 10 adapatation
-
-namespace JCS
-{
- ///
- /// Provides detailed information about the host operating system.
- ///
- public static class OSVersionInfo
- {
- #region ENUMS
- public enum SoftwareArchitecture
- {
- Unknown = 0,
- Bit32 = 1,
- Bit64 = 2
- }
-
- public enum ProcessorArchitecture
- {
- Unknown = 0,
- Bit32 = 1,
- Bit64 = 2,
- Itanium64 = 3
- }
- #endregion ENUMS
-
- #region DELEGATE DECLARATION
- private delegate bool IsWow64ProcessDelegate([In] IntPtr handle, [Out] out bool isWow64Process);
- #endregion DELEGATE DECLARATION
-
- #region BITS
- ///
- /// Determines if the current application is 32 or 64-bit.
- ///
- static public SoftwareArchitecture ProgramBits
- {
- get
- {
- SoftwareArchitecture pbits = SoftwareArchitecture.Unknown;
-
- System.Collections.IDictionary test = Environment.GetEnvironmentVariables();
-
- switch (IntPtr.Size * 8)
- {
- case 64:
- pbits = SoftwareArchitecture.Bit64;
- break;
-
- case 32:
- pbits = SoftwareArchitecture.Bit32;
- break;
-
- default:
- pbits = SoftwareArchitecture.Unknown;
- break;
- }
-
- return pbits;
- }
- }
-
- static public SoftwareArchitecture OSBits
- {
- get
- {
- SoftwareArchitecture osbits = SoftwareArchitecture.Unknown;
-
- switch (IntPtr.Size * 8)
- {
- case 64:
- osbits = SoftwareArchitecture.Bit64;
- break;
-
- case 32:
- if (Is32BitProcessOn64BitProcessor())
- osbits = SoftwareArchitecture.Bit64;
- else
- osbits = SoftwareArchitecture.Bit32;
- break;
-
- default:
- osbits = SoftwareArchitecture.Unknown;
- break;
- }
-
- return osbits;
- }
- }
-
- ///
- /// Determines if the current processor is 32 or 64-bit.
- ///
- static public ProcessorArchitecture ProcessorBits
- {
- get
- {
- ProcessorArchitecture pbits = ProcessorArchitecture.Unknown;
-
- try
- {
- SYSTEM_INFO l_System_Info = new SYSTEM_INFO();
- GetNativeSystemInfo(ref l_System_Info);
-
- switch (l_System_Info.uProcessorInfo.wProcessorArchitecture)
- {
- case 9: // PROCESSOR_ARCHITECTURE_AMD64
- pbits = ProcessorArchitecture.Bit64;
- break;
- case 6: // PROCESSOR_ARCHITECTURE_IA64
- pbits = ProcessorArchitecture.Itanium64;
- break;
- case 0: // PROCESSOR_ARCHITECTURE_INTEL
- pbits = ProcessorArchitecture.Bit32;
- break;
- default: // PROCESSOR_ARCHITECTURE_UNKNOWN
- pbits = ProcessorArchitecture.Unknown;
- break;
- }
- }
- catch
- {
- // Ignore
- }
-
- return pbits;
- }
- }
- #endregion BITS
-
- #region EDITION
- static private string s_Edition;
- ///
- /// Gets the edition of the operating system running on this computer.
- ///
- static public string Edition
- {
- get
- {
- if (s_Edition != null)
- return s_Edition; //***** RETURN *****//
-
- string edition = String.Empty;
-
- OperatingSystem osVersion = Environment.OSVersion;
- OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
- osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
-
- if (GetVersionEx(ref osVersionInfo))
- {
- int majorVersion = osVersion.Version.Major;
- int minorVersion = osVersion.Version.Minor;
- byte productType = osVersionInfo.wProductType;
- short suiteMask = osVersionInfo.wSuiteMask;
-
- #region VERSION 4
- if (majorVersion == 4)
- {
- if (productType == VER_NT_WORKSTATION)
- {
- // Windows NT 4.0 Workstation
- edition = "Workstation";
- }
- else if (productType == VER_NT_SERVER)
- {
- if ((suiteMask & VER_SUITE_ENTERPRISE) != 0)
- {
- // Windows NT 4.0 Server Enterprise
- edition = "Enterprise Server";
- }
- else
- {
- // Windows NT 4.0 Server
- edition = "Standard Server";
- }
- }
- }
- #endregion VERSION 4
-
- #region VERSION 5
- else if (majorVersion == 5)
- {
- if (productType == VER_NT_WORKSTATION)
- {
- if ((suiteMask & VER_SUITE_PERSONAL) != 0)
- {
- edition = "Home";
- }
- else
- {
- if (GetSystemMetrics(86) == 0) // 86 == SM_TABLETPC
- edition = "Professional";
- else
- edition = "Tablet Edition";
- }
- }
- else if (productType == VER_NT_SERVER)
- {
- if (minorVersion == 0)
- {
- if ((suiteMask & VER_SUITE_DATACENTER) != 0)
- {
- // Windows 2000 Datacenter Server
- edition = "Datacenter Server";
- }
- else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0)
- {
- // Windows 2000 Advanced Server
- edition = "Advanced Server";
- }
- else
- {
- // Windows 2000 Server
- edition = "Server";
- }
- }
- else
- {
- if ((suiteMask & VER_SUITE_DATACENTER) != 0)
- {
- // Windows Server 2003 Datacenter Edition
- edition = "Datacenter";
- }
- else if ((suiteMask & VER_SUITE_ENTERPRISE) != 0)
- {
- // Windows Server 2003 Enterprise Edition
- edition = "Enterprise";
- }
- else if ((suiteMask & VER_SUITE_BLADE) != 0)
- {
- // Windows Server 2003 Web Edition
- edition = "Web Edition";
- }
- else
- {
- // Windows Server 2003 Standard Edition
- edition = "Standard";
- }
- }
- }
- }
- #endregion VERSION 5
-
- #region VERSION 6
- else if (majorVersion == 6)
- {
- int ed;
- if (GetProductInfo(majorVersion, minorVersion,
- osVersionInfo.wServicePackMajor, osVersionInfo.wServicePackMinor,
- out ed))
- {
- switch (ed)
- {
- case PRODUCT_BUSINESS:
- edition = "Business";
- break;
- case PRODUCT_BUSINESS_N:
- edition = "Business N";
- break;
- case PRODUCT_CLUSTER_SERVER:
- edition = "HPC Edition";
- break;
- case PRODUCT_CLUSTER_SERVER_V:
- edition = "HPC Edition without Hyper-V";
- break;
- case PRODUCT_DATACENTER_SERVER:
- edition = "Datacenter Server";
- break;
- case PRODUCT_DATACENTER_SERVER_CORE:
- edition = "Datacenter Server (core installation)";
- break;
- case PRODUCT_DATACENTER_SERVER_V:
- edition = "Datacenter Server without Hyper-V";
- break;
- case PRODUCT_DATACENTER_SERVER_CORE_V:
- edition = "Datacenter Server without Hyper-V (core installation)";
- break;
- case PRODUCT_EMBEDDED:
- edition = "Embedded";
- break;
- case PRODUCT_ENTERPRISE:
- edition = "Enterprise";
- break;
- case PRODUCT_ENTERPRISE_N:
- edition = "Enterprise N";
- break;
- case PRODUCT_ENTERPRISE_E:
- edition = "Enterprise E";
- break;
- case PRODUCT_ENTERPRISE_SERVER:
- edition = "Enterprise Server";
- break;
- case PRODUCT_ENTERPRISE_SERVER_CORE:
- edition = "Enterprise Server (core installation)";
- break;
- case PRODUCT_ENTERPRISE_SERVER_CORE_V:
- edition = "Enterprise Server without Hyper-V (core installation)";
- break;
- case PRODUCT_ENTERPRISE_SERVER_IA64:
- edition = "Enterprise Server for Itanium-based Systems";
- break;
- case PRODUCT_ENTERPRISE_SERVER_V:
- edition = "Enterprise Server without Hyper-V";
- break;
- case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT:
- edition = "Essential Business Server MGMT";
- break;
- case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL:
- edition = "Essential Business Server ADDL";
- break;
- case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC:
- edition = "Essential Business Server MGMTSVC";
- break;
- case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC:
- edition = "Essential Business Server ADDLSVC";
- break;
- case PRODUCT_HOME_BASIC:
- edition = "Home Basic";
- break;
- case PRODUCT_HOME_BASIC_N:
- edition = "Home Basic N";
- break;
- case PRODUCT_HOME_BASIC_E:
- edition = "Home Basic E";
- break;
- case PRODUCT_HOME_PREMIUM:
- edition = "Home Premium";
- break;
- case PRODUCT_HOME_PREMIUM_N:
- edition = "Home Premium N";
- break;
- case PRODUCT_HOME_PREMIUM_E:
- edition = "Home Premium E";
- break;
- case PRODUCT_HOME_PREMIUM_SERVER:
- edition = "Home Premium Server";
- break;
- case PRODUCT_HYPERV:
- edition = "Microsoft Hyper-V Server";
- break;
- case PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT:
- edition = "Windows Essential Business Management Server";
- break;
- case PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING:
- edition = "Windows Essential Business Messaging Server";
- break;
- case PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY:
- edition = "Windows Essential Business Security Server";
- break;
- case PRODUCT_PROFESSIONAL:
- edition = "Professional";
- break;
- case PRODUCT_PROFESSIONAL_N:
- edition = "Professional N";
- break;
- case PRODUCT_PROFESSIONAL_E:
- edition = "Professional E";
- break;
- case PRODUCT_SB_SOLUTION_SERVER:
- edition = "SB Solution Server";
- break;
- case PRODUCT_SB_SOLUTION_SERVER_EM:
- edition = "SB Solution Server EM";
- break;
- case PRODUCT_SERVER_FOR_SB_SOLUTIONS:
- edition = "Server for SB Solutions";
- break;
- case PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM:
- edition = "Server for SB Solutions EM";
- break;
- case PRODUCT_SERVER_FOR_SMALLBUSINESS:
- edition = "Windows Essential Server Solutions";
- break;
- case PRODUCT_SERVER_FOR_SMALLBUSINESS_V:
- edition = "Windows Essential Server Solutions without Hyper-V";
- break;
- case PRODUCT_SERVER_FOUNDATION:
- edition = "Server Foundation";
- break;
- case PRODUCT_SMALLBUSINESS_SERVER:
- edition = "Windows Small Business Server";
- break;
- case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
- edition = "Windows Small Business Server Premium";
- break;
- case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE:
- edition = "Windows Small Business Server Premium (core installation)";
- break;
- case PRODUCT_SOLUTION_EMBEDDEDSERVER:
- edition = "Solution Embedded Server";
- break;
- case PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE:
- edition = "Solution Embedded Server (core installation)";
- break;
- case PRODUCT_STANDARD_SERVER:
- edition = "Standard Server";
- break;
- case PRODUCT_STANDARD_SERVER_CORE:
- edition = "Standard Server (core installation)";
- break;
- case PRODUCT_STANDARD_SERVER_SOLUTIONS:
- edition = "Standard Server Solutions";
- break;
- case PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE:
- edition = "Standard Server Solutions (core installation)";
- break;
- case PRODUCT_STANDARD_SERVER_CORE_V:
- edition = "Standard Server without Hyper-V (core installation)";
- break;
- case PRODUCT_STANDARD_SERVER_V:
- edition = "Standard Server without Hyper-V";
- break;
- case PRODUCT_STARTER:
- edition = "Starter";
- break;
- case PRODUCT_STARTER_N:
- edition = "Starter N";
- break;
- case PRODUCT_STARTER_E:
- edition = "Starter E";
- break;
- case PRODUCT_STORAGE_ENTERPRISE_SERVER:
- edition = "Enterprise Storage Server";
- break;
- case PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE:
- edition = "Enterprise Storage Server (core installation)";
- break;
- case PRODUCT_STORAGE_EXPRESS_SERVER:
- edition = "Express Storage Server";
- break;
- case PRODUCT_STORAGE_EXPRESS_SERVER_CORE:
- edition = "Express Storage Server (core installation)";
- break;
- case PRODUCT_STORAGE_STANDARD_SERVER:
- edition = "Standard Storage Server";
- break;
- case PRODUCT_STORAGE_STANDARD_SERVER_CORE:
- edition = "Standard Storage Server (core installation)";
- break;
- case PRODUCT_STORAGE_WORKGROUP_SERVER:
- edition = "Workgroup Storage Server";
- break;
- case PRODUCT_STORAGE_WORKGROUP_SERVER_CORE:
- edition = "Workgroup Storage Server (core installation)";
- break;
- case PRODUCT_UNDEFINED:
- edition = "Unknown product";
- break;
- case PRODUCT_ULTIMATE:
- edition = "Ultimate";
- break;
- case PRODUCT_ULTIMATE_N:
- edition = "Ultimate N";
- break;
- case PRODUCT_ULTIMATE_E:
- edition = "Ultimate E";
- break;
- case PRODUCT_WEB_SERVER:
- edition = "Web Server";
- break;
- case PRODUCT_WEB_SERVER_CORE:
- edition = "Web Server (core installation)";
- break;
- }
- }
- }
- #endregion VERSION 6
- }
-
- s_Edition = edition;
- return edition;
- }
- }
- #endregion EDITION
-
- #region NAME
- static private string s_Name;
- ///
- /// Gets the name of the operating system running on this computer.
- ///
- static public string Name
- {
- get
- {
- if (s_Name != null)
- return s_Name; //***** RETURN *****//
-
- string name = "unknown";
-
- OperatingSystem osVersion = Environment.OSVersion;
- OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
- osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
-
- if (GetVersionEx(ref osVersionInfo))
- {
- int majorVersion = osVersion.Version.Major;
- int minorVersion = osVersion.Version.Minor;
-
- if (majorVersion == 6 && minorVersion == 2)
- {
- //The registry read workaround is by Scott Vickery. Thanks a lot for the help!
-
- //http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
-
- // For applications that have been manifested for Windows 8.1 & Windows 10. Applications not manifested for 8.1 or 10 will return the Windows 8 OS version value (6.2).
- // By reading the registry, we'll get the exact version - meaning we can even compare against Win 8 and Win 8.1.
- string exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion", "");
- if (!string.IsNullOrEmpty(exactVersion))
- {
- string[] splitResult = exactVersion.Split('.');
- majorVersion = Convert.ToInt32(splitResult[0]);
- minorVersion = Convert.ToInt32(splitResult[1]);
- }
- if (IsWindows10())
- {
- majorVersion = 10;
- minorVersion = 0;
- }
- }
-
- switch (osVersion.Platform)
- {
- case PlatformID.Win32S:
- name = "Windows 3.1";
- break;
- case PlatformID.WinCE:
- name = "Windows CE";
- break;
- case PlatformID.Win32Windows:
- {
- if (majorVersion == 4)
- {
- string csdVersion = osVersionInfo.szCSDVersion;
- switch (minorVersion)
- {
- case 0:
- if (csdVersion == "B" || csdVersion == "C")
- name = "Windows 95 OSR2";
- else
- name = "Windows 95";
- break;
- case 10:
- if (csdVersion == "A")
- name = "Windows 98 Second Edition";
- else
- name = "Windows 98";
- break;
- case 90:
- name = "Windows Me";
- break;
- }
- }
- break;
- }
- case PlatformID.Win32NT:
- {
- byte productType = osVersionInfo.wProductType;
-
- switch (majorVersion)
- {
- case 3:
- name = "Windows NT 3.51";
- break;
- case 4:
- switch (productType)
- {
- case 1:
- name = "Windows NT 4.0";
- break;
- case 3:
- name = "Windows NT 4.0 Server";
- break;
- }
- break;
- case 5:
- switch (minorVersion)
- {
- case 0:
- name = "Windows 2000";
- break;
- case 1:
- name = "Windows XP";
- break;
- case 2:
- name = "Windows Server 2003";
- break;
- }
- break;
- case 6:
- switch (minorVersion)
- {
- case 0:
- switch (productType)
- {
- case 1:
- name = "Windows Vista";
- break;
- case 3:
- name = "Windows Server 2008";
- break;
- }
- break;
-
- case 1:
- switch (productType)
- {
- case 1:
- name = "Windows 7";
- break;
- case 3:
- name = "Windows Server 2008 R2";
- break;
- }
- break;
- case 2:
- switch (productType)
- {
- case 1:
- name = "Windows 8";
- break;
- case 3:
- name = "Windows Server 2012";
- break;
- }
- break;
- case 3:
- switch (productType)
- {
- case 1:
- name = "Windows 8.1";
- break;
- case 3:
- name = "Windows Server 2012 R2";
- break;
- }
- break;
- }
- break;
- case 10:
- switch (minorVersion)
- {
- case 0:
- switch (productType)
- {
- case 1:
- name = "Windows 10";
- break;
- case 3:
- name = "Windows Server 2016";
- break;
- }
- break;
- }
- break;
- }
- break;
- }
- }
- }
-
- s_Name = name;
- return name;
- }
- }
- #endregion NAME
-
- #region PINVOKE
-
- #region GET
- #region PRODUCT INFO
- [DllImport("Kernel32.dll")]
- internal static extern bool GetProductInfo(
- int osMajorVersion,
- int osMinorVersion,
- int spMajorVersion,
- int spMinorVersion,
- out int edition);
- #endregion PRODUCT INFO
-
- #region VERSION
- [DllImport("kernel32.dll")]
- private static extern bool GetVersionEx(ref OSVERSIONINFOEX osVersionInfo);
- #endregion VERSION
-
- #region SYSTEMMETRICS
- [DllImport("user32")]
- public static extern int GetSystemMetrics(int nIndex);
- #endregion SYSTEMMETRICS
-
- #region SYSTEMINFO
- [DllImport("kernel32.dll")]
- public static extern void GetSystemInfo([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_INFO lpSystemInfo);
-
- [DllImport("kernel32.dll")]
- public static extern void GetNativeSystemInfo([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_INFO lpSystemInfo);
- #endregion SYSTEMINFO
-
- #endregion GET
-
- #region OSVERSIONINFOEX
- [StructLayout(LayoutKind.Sequential)]
- private struct OSVERSIONINFOEX
- {
- public int dwOSVersionInfoSize;
- public int dwMajorVersion;
- public int dwMinorVersion;
- public int dwBuildNumber;
- public int dwPlatformId;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
- public string szCSDVersion;
- public short wServicePackMajor;
- public short wServicePackMinor;
- public short wSuiteMask;
- public byte wProductType;
- public byte wReserved;
- }
- #endregion OSVERSIONINFOEX
-
- #region SYSTEM_INFO
- [StructLayout(LayoutKind.Sequential)]
- public struct SYSTEM_INFO
- {
- internal _PROCESSOR_INFO_UNION uProcessorInfo;
- public uint dwPageSize;
- public IntPtr lpMinimumApplicationAddress;
- public IntPtr lpMaximumApplicationAddress;
- public IntPtr dwActiveProcessorMask;
- public uint dwNumberOfProcessors;
- public uint dwProcessorType;
- public uint dwAllocationGranularity;
- public ushort dwProcessorLevel;
- public ushort dwProcessorRevision;
- }
- #endregion SYSTEM_INFO
-
- #region _PROCESSOR_INFO_UNION
- [StructLayout(LayoutKind.Explicit)]
- public struct _PROCESSOR_INFO_UNION
- {
- [FieldOffset(0)]
- internal uint dwOemId;
- [FieldOffset(0)]
- internal ushort wProcessorArchitecture;
- [FieldOffset(2)]
- internal ushort wReserved;
- }
- #endregion _PROCESSOR_INFO_UNION
-
- #region 64 BIT OS DETECTION
- [DllImport("kernel32", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
- public extern static IntPtr LoadLibrary(string libraryName);
-
- [DllImport("kernel32", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
- public extern static IntPtr GetProcAddress(IntPtr hwnd, string procedureName);
- #endregion 64 BIT OS DETECTION
-
- #region PRODUCT
- private const int PRODUCT_UNDEFINED = 0x00000000;
- private const int PRODUCT_ULTIMATE = 0x00000001;
- private const int PRODUCT_HOME_BASIC = 0x00000002;
- private const int PRODUCT_HOME_PREMIUM = 0x00000003;
- private const int PRODUCT_ENTERPRISE = 0x00000004;
- private const int PRODUCT_HOME_BASIC_N = 0x00000005;
- private const int PRODUCT_BUSINESS = 0x00000006;
- private const int PRODUCT_STANDARD_SERVER = 0x00000007;
- private const int PRODUCT_DATACENTER_SERVER = 0x00000008;
- private const int PRODUCT_SMALLBUSINESS_SERVER = 0x00000009;
- private const int PRODUCT_ENTERPRISE_SERVER = 0x0000000A;
- private const int PRODUCT_STARTER = 0x0000000B;
- private const int PRODUCT_DATACENTER_SERVER_CORE = 0x0000000C;
- private const int PRODUCT_STANDARD_SERVER_CORE = 0x0000000D;
- private const int PRODUCT_ENTERPRISE_SERVER_CORE = 0x0000000E;
- private const int PRODUCT_ENTERPRISE_SERVER_IA64 = 0x0000000F;
- private const int PRODUCT_BUSINESS_N = 0x00000010;
- private const int PRODUCT_WEB_SERVER = 0x00000011;
- private const int PRODUCT_CLUSTER_SERVER = 0x00000012;
- private const int PRODUCT_HOME_SERVER = 0x00000013;
- private const int PRODUCT_STORAGE_EXPRESS_SERVER = 0x00000014;
- private const int PRODUCT_STORAGE_STANDARD_SERVER = 0x00000015;
- private const int PRODUCT_STORAGE_WORKGROUP_SERVER = 0x00000016;
- private const int PRODUCT_STORAGE_ENTERPRISE_SERVER = 0x00000017;
- private const int PRODUCT_SERVER_FOR_SMALLBUSINESS = 0x00000018;
- private const int PRODUCT_SMALLBUSINESS_SERVER_PREMIUM = 0x00000019;
- private const int PRODUCT_HOME_PREMIUM_N = 0x0000001A;
- private const int PRODUCT_ENTERPRISE_N = 0x0000001B;
- private const int PRODUCT_ULTIMATE_N = 0x0000001C;
- private const int PRODUCT_WEB_SERVER_CORE = 0x0000001D;
- private const int PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT = 0x0000001E;
- private const int PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY = 0x0000001F;
- private const int PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING = 0x00000020;
- private const int PRODUCT_SERVER_FOUNDATION = 0x00000021;
- private const int PRODUCT_HOME_PREMIUM_SERVER = 0x00000022;
- private const int PRODUCT_SERVER_FOR_SMALLBUSINESS_V = 0x00000023;
- private const int PRODUCT_STANDARD_SERVER_V = 0x00000024;
- private const int PRODUCT_DATACENTER_SERVER_V = 0x00000025;
- private const int PRODUCT_ENTERPRISE_SERVER_V = 0x00000026;
- private const int PRODUCT_DATACENTER_SERVER_CORE_V = 0x00000027;
- private const int PRODUCT_STANDARD_SERVER_CORE_V = 0x00000028;
- private const int PRODUCT_ENTERPRISE_SERVER_CORE_V = 0x00000029;
- private const int PRODUCT_HYPERV = 0x0000002A;
- private const int PRODUCT_STORAGE_EXPRESS_SERVER_CORE = 0x0000002B;
- private const int PRODUCT_STORAGE_STANDARD_SERVER_CORE = 0x0000002C;
- private const int PRODUCT_STORAGE_WORKGROUP_SERVER_CORE = 0x0000002D;
- private const int PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE = 0x0000002E;
- private const int PRODUCT_STARTER_N = 0x0000002F;
- private const int PRODUCT_PROFESSIONAL = 0x00000030;
- private const int PRODUCT_PROFESSIONAL_N = 0x00000031;
- private const int PRODUCT_SB_SOLUTION_SERVER = 0x00000032;
- private const int PRODUCT_SERVER_FOR_SB_SOLUTIONS = 0x00000033;
- private const int PRODUCT_STANDARD_SERVER_SOLUTIONS = 0x00000034;
- private const int PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE = 0x00000035;
- private const int PRODUCT_SB_SOLUTION_SERVER_EM = 0x00000036;
- private const int PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM = 0x00000037;
- private const int PRODUCT_SOLUTION_EMBEDDEDSERVER = 0x00000038;
- private const int PRODUCT_SOLUTION_EMBEDDEDSERVER_CORE = 0x00000039;
- //private const int ???? = 0x0000003A;
- private const int PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT = 0x0000003B;
- private const int PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL = 0x0000003C;
- private const int PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC = 0x0000003D;
- private const int PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC = 0x0000003E;
- private const int PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE = 0x0000003F;
- private const int PRODUCT_CLUSTER_SERVER_V = 0x00000040;
- private const int PRODUCT_EMBEDDED = 0x00000041;
- private const int PRODUCT_STARTER_E = 0x00000042;
- private const int PRODUCT_HOME_BASIC_E = 0x00000043;
- private const int PRODUCT_HOME_PREMIUM_E = 0x00000044;
- private const int PRODUCT_PROFESSIONAL_E = 0x00000045;
- private const int PRODUCT_ENTERPRISE_E = 0x00000046;
- private const int PRODUCT_ULTIMATE_E = 0x00000047;
- //private const int PRODUCT_UNLICENSED = 0xABCDABCD;
- #endregion PRODUCT
-
- #region VERSIONS
- private const int VER_NT_WORKSTATION = 1;
- private const int VER_NT_DOMAIN_CONTROLLER = 2;
- private const int VER_NT_SERVER = 3;
- private const int VER_SUITE_SMALLBUSINESS = 1;
- private const int VER_SUITE_ENTERPRISE = 2;
- private const int VER_SUITE_TERMINAL = 16;
- private const int VER_SUITE_DATACENTER = 128;
- private const int VER_SUITE_SINGLEUSERTS = 256;
- private const int VER_SUITE_PERSONAL = 512;
- private const int VER_SUITE_BLADE = 1024;
- #endregion VERSIONS
-
- #endregion PINVOKE
-
- #region SERVICE PACK
- ///
- /// Gets the service pack information of the operating system running on this computer.
- ///
- static public string ServicePack
- {
- get
- {
- string servicePack = String.Empty;
- OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
-
- osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
-
- if (GetVersionEx(ref osVersionInfo))
- {
- servicePack = osVersionInfo.szCSDVersion;
- }
-
- return servicePack;
- }
- }
- #endregion SERVICE PACK
-
- #region VERSION
- #region BUILD
- ///
- /// Gets the build version number of the operating system running on this computer.
- ///
- static public int BuildVersion
- {
- get
- {
- return int.Parse(RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuildNumber", "0"));
- }
- }
- #endregion BUILD
-
- #region FULL
- #region STRING
- ///
- /// Gets the full version string of the operating system running on this computer.
- ///
- static public string VersionString
- {
- get
- {
- return Version.ToString();
- }
- }
- #endregion STRING
-
- #region VERSION
- ///
- /// Gets the full version of the operating system running on this computer.
- ///
- static public Version Version
- {
- get
- {
- return new Version(MajorVersion, MinorVersion, BuildVersion, RevisionVersion);
- }
- }
- #endregion VERSION
- #endregion FULL
-
- #region MAJOR
- ///
- /// Gets the major version number of the operating system running on this computer.
- ///
- static public int MajorVersion
- {
- get
- {
- if(IsWindows10())
- {
- return 10;
- }
- string exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion", "");
- if(!string.IsNullOrEmpty(exactVersion))
- {
- string[] splitVersion = exactVersion.Split('.');
- return int.Parse(splitVersion[0]);
- }
- return Environment.OSVersion.Version.Major;
- }
- }
- #endregion MAJOR
-
- #region MINOR
- ///
- /// Gets the minor version number of the operating system running on this computer.
- ///
- static public int MinorVersion
- {
- get
- {
- if (IsWindows10())
- {
- return 0;
- }
- string exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion", "");
- if (!string.IsNullOrEmpty(exactVersion))
- {
- string[] splitVersion = exactVersion.Split('.');
- return int.Parse(splitVersion[1]);
- }
- return Environment.OSVersion.Version.Minor;
- }
- }
- #endregion MINOR
-
- #region REVISION
- ///
- /// Gets the revision version number of the operating system running on this computer.
- ///
- static public int RevisionVersion
- {
- get
- {
- if(IsWindows10())
- {
- return 0;
- }
- return Environment.OSVersion.Version.Revision;
- }
- }
- #endregion REVISION
- #endregion VERSION
-
- #region 64 BIT OS DETECTION
- private static IsWow64ProcessDelegate GetIsWow64ProcessDelegate()
- {
- IntPtr handle = LoadLibrary("kernel32");
-
- if (handle != IntPtr.Zero)
- {
- IntPtr fnPtr = GetProcAddress(handle, "IsWow64Process");
-
- if (fnPtr != IntPtr.Zero)
- {
- return (IsWow64ProcessDelegate)Marshal.GetDelegateForFunctionPointer((IntPtr)fnPtr, typeof(IsWow64ProcessDelegate));
- }
- }
-
- return null;
- }
-
- private static bool Is32BitProcessOn64BitProcessor()
- {
- IsWow64ProcessDelegate fnDelegate = GetIsWow64ProcessDelegate();
-
- if (fnDelegate == null)
- {
- return false;
- }
-
- bool isWow64;
- bool retVal = fnDelegate.Invoke(Process.GetCurrentProcess().Handle, out isWow64);
-
- if (retVal == false)
- {
- return false;
- }
-
- return isWow64;
- }
- #endregion 64 BIT OS DETECTION
-
- #region Windows 10 Detection
-
- private static bool IsWindows10()
- {
- string productName = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", "");
- if (productName.StartsWith("Windows 10", StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- return false;
- }
-
- #endregion
-
- #region Registry Methods
-
- private static string RegistryRead(string RegistryPath, string Field, string DefaultValue)
- {
- string rtn = "";
- string backSlash = "";
- string newRegistryPath = "";
-
- try
- {
- RegistryKey OurKey = null;
- string[] split_result = RegistryPath.Split('\\');
-
- if (split_result.Length > 0)
- {
- split_result[0] = split_result[0].ToUpper(); // Make the first entry uppercase...
-
- if (split_result[0] == "HKEY_CLASSES_ROOT") OurKey = Registry.ClassesRoot;
- else if (split_result[0] == "HKEY_CURRENT_USER") OurKey = Registry.CurrentUser;
- else if (split_result[0] == "HKEY_LOCAL_MACHINE") OurKey = Registry.LocalMachine;
- else if (split_result[0] == "HKEY_USERS") OurKey = Registry.Users;
- else if (split_result[0] == "HKEY_CURRENT_CONFIG") OurKey = Registry.CurrentConfig;
-
- if (OurKey != null)
- {
- for (int i = 1; i < split_result.Length; i++)
- {
- newRegistryPath += backSlash + split_result[i];
- backSlash = "\\";
- }
-
- if (newRegistryPath != "")
- {
- //rtn = (string)Registry.GetValue(RegistryPath, "CurrentVersion", DefaultValue);
-
- OurKey = OurKey.OpenSubKey(newRegistryPath);
- rtn = (string)OurKey.GetValue(Field, DefaultValue);
- OurKey.Close();
- }
- }
- }
- }
- catch { }
-
- return rtn;
- }
-
- #endregion Registry Methods
- }
-}
diff --git a/OSVersionInfoDLL/OSVersionInfoDLL.csproj b/OSVersionInfoDLL/OSVersionInfoDLL.csproj
deleted file mode 100644
index 6586a34..0000000
--- a/OSVersionInfoDLL/OSVersionInfoDLL.csproj
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 9.0.30729
- 2.0
- {9599DF4F-9D56-4448-8F56-76B3966982A4}
- Library
- Properties
- JCS
- OSVersionInfo
- v2.0
- 512
-
-
-
-
-
-
- 3.5
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- false
-
-
-
-
- 3.5
-
-
- 3.5
-
-
-
-
-
-
-
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- True
- Resources.resx
- True
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
- True
- Settings.settings
- True
-
-
-
-
-
\ No newline at end of file
diff --git a/OSVersionInfoDLL/Properties/AssemblyInfo.cs b/OSVersionInfoDLL/Properties/AssemblyInfo.cs
deleted file mode 100644
index 6cc03ab..0000000
--- a/OSVersionInfoDLL/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-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("OSVersionInfoDLL")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("OSVersionInfoDLL")]
-[assembly: AssemblyCopyright("Copyright © 2010-2016")]
-[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("a3be4af5-b38a-442d-a0a8-8c63450c2888")]
-
-// 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("3.0.0.0")]
-[assembly: AssemblyFileVersion("3.0.0.0")]
diff --git a/OSVersionInfoDLL/Properties/Resources.Designer.cs b/OSVersionInfoDLL/Properties/Resources.Designer.cs
deleted file mode 100644
index ba26196..0000000
--- a/OSVersionInfoDLL/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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.
-//
-//------------------------------------------------------------------------------
-
-namespace JCS.Properties {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // 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", "4.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() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [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("JCS.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/OSVersionInfoDLL/Properties/Resources.resx b/OSVersionInfoDLL/Properties/Resources.resx
deleted file mode 100644
index af7dbeb..0000000
--- a/OSVersionInfoDLL/Properties/Resources.resx
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/OSVersionInfoDLL/Properties/Settings.Designer.cs b/OSVersionInfoDLL/Properties/Settings.Designer.cs
deleted file mode 100644
index 9699ff6..0000000
--- a/OSVersionInfoDLL/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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.
-//
-//------------------------------------------------------------------------------
-
-namespace JCS.Properties {
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.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;
- }
- }
- }
-}
diff --git a/OSVersionInfoDLL/Properties/Settings.settings b/OSVersionInfoDLL/Properties/Settings.settings
deleted file mode 100644
index 3964565..0000000
--- a/OSVersionInfoDLL/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/OSVersionInfoDLL/app.config b/OSVersionInfoDLL/app.config
deleted file mode 100644
index ea93c85..0000000
--- a/OSVersionInfoDLL/app.config
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-