diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj
index 4baef38..dc75b16 100644
--- a/EnvyUpdate/EnvyUpdate.csproj
+++ b/EnvyUpdate/EnvyUpdate.csproj
@@ -54,6 +54,9 @@
MinimumRecommendedRules.ruleset
true
+
+ app.manifest
+
..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll
@@ -131,6 +134,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+
SettingsSingleFileGenerator
@@ -157,6 +161,9 @@
True
+
+
+
diff --git a/EnvyUpdate/MainWindow.xaml b/EnvyUpdate/MainWindow.xaml
index 2976a4c..ff8f697 100644
--- a/EnvyUpdate/MainWindow.xaml
+++ b/EnvyUpdate/MainWindow.xaml
@@ -6,16 +6,15 @@
xmlns:local="clr-namespace:EnvyUpdate"
xmlns:tb="http://www.hardcodet.net/taskbar"
mc:Ignorable="d"
- Title="EnvyUpdate" Height="170" Width="463" Icon="icon.ico" ResizeMode="CanMinimize" StateChanged="Window_StateChanged" Closing="Window_Closing">
+ Title="EnvyUpdate" Height="132.5" Width="463" Icon="icon.ico" ResizeMode="CanMinimize" StateChanged="Window_StateChanged" Closing="Window_Closing">
-
-
+
diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs
index 92c07cd..72ab520 100644
--- a/EnvyUpdate/MainWindow.xaml.cs
+++ b/EnvyUpdate/MainWindow.xaml.cs
@@ -1,4 +1,5 @@
using System;
+using System.Globalization;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
@@ -21,7 +22,7 @@ namespace EnvyUpdate
private readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location;
private readonly string exepath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\";
private readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
- private readonly string version = "1.4";
+ private readonly string version = "2.0";
private string argument = null;
public MainWindow()
@@ -47,11 +48,7 @@ namespace EnvyUpdate
MessageBox.Show("Application is already running.");
Environment.Exit(1);
}
- if (!Directory.Exists(appdata))
- {
- Directory.CreateDirectory(appdata);
- }
- // Check if application is in Autorun mode and update
+ // Check if application is installed and update
if (exepath == appdata)
{
try
@@ -65,6 +62,10 @@ namespace EnvyUpdate
{
// Silently fail.
}
+ // Also set correct ticks.
+ chkInstall.IsChecked = true;
+ if (File.Exists(startup + "\\EnvyUpdate.lnk"))
+ chkAutostart.IsChecked = true;
}
if (Util.GetLocDriv() != null)
{
@@ -85,19 +86,11 @@ namespace EnvyUpdate
}
}
- if (File.Exists(appdata + "nvidia-update.txt"))
- {
- chkPortable.IsChecked = false;
- DispatcherTimer Dt = new DispatcherTimer();
- Dt.Tick += new EventHandler(Dt_Tick);
- Dt.Interval = new TimeSpan(5, 0, 0);
- Dt.Start();
- Load();
- }
- if (File.Exists(startup + "\\EnvyUpdate.lnk"))
- {
- chkAutostart.IsChecked = true;
- }
+ DispatcherTimer Dt = new DispatcherTimer();
+ Dt.Tick += new EventHandler(Dt_Tick);
+ Dt.Interval = new TimeSpan(5, 0, 0);
+ Dt.Start();
+ Load();
}
private void Dt_Tick(object sender, EventArgs e)
@@ -112,38 +105,17 @@ namespace EnvyUpdate
//System.Diagnostics.Process.Start("https://github.com/fyr77/EnvyUpdate/");
}
- private void Grid_Drop(object sender, DragEventArgs e)
- {
- if (e.Data.GetDataPresent(DataFormats.FileDrop))
- {
- try
- {
- string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
- Load(files);
- }
- catch (WebException)
- {
- MessageBox.Show("Network Error. Are you connected to the internet?", "Network Error");
- }
- }
- }
-
private void Load()
{
- FileInfo f = new FileInfo(appdata + "nvidia-update.txt");
-
int psid;
int pfid;
int osid;
- int langid;
+ //int langid;
- chkPortable.Visibility = Visibility.Hidden;
- labelDrag.Content = "Drag nvidia.com-cookies.txt here if you have changed your graphics card.";
- psid = Util.GetData(f.FullName, "ProductSeries");
- pfid = Util.GetData(f.FullName, "ProductType");
- osid = Util.GetData(f.FullName, "OperatingSystem");
- langid = Util.GetData(f.FullName, "Language");
- gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString() + "&lid=" + langid.ToString();
+ psid = Util.GetIDs("psid");
+ pfid = Util.GetIDs("pfid");
+ osid = Util.GetIDs("osid");
+ gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString(); // + "&lid=" + langid.ToString();
WebClient c = new WebClient();
gpuURL = c.DownloadString(gpuURL);
string pContent = c.DownloadString(gpuURL);
@@ -170,50 +142,6 @@ namespace EnvyUpdate
}
}
- private void Load(string[] files)
- {
- FileInfo f = new FileInfo(files[0]);
-
- int psid;
- int pfid;
- int osid;
- int langid;
-
- if (chkPortable.IsChecked == false)
- {
- File.Copy(f.FullName, appdata + "nvidia-update.txt", true);
- f = new FileInfo(appdata + "nvidia-update.txt");
-
- chkPortable.Visibility = Visibility.Hidden;
- labelDrag.Content = "Drag nvidia.com-cookies.txt here if you have changed your graphics card.";
- }
- psid = Util.GetData(f.FullName, "ProductSeries");
- pfid = Util.GetData(f.FullName, "ProductType");
- osid = Util.GetData(f.FullName, "OperatingSystem");
- langid = Util.GetData(f.FullName, "Language");
- gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&rpf=1&osid=" + osid.ToString() + "&lid=" + langid.ToString() + "&ctk=0";
- string pContent = null;
- using (WebClient c = new WebClient())
- {
- gpuURL = c.DownloadString(gpuURL);
- pContent = c.DownloadString(gpuURL);
- }
- var pattern = @"\d{3}\.\d{2} ";
- Regex rgx = new Regex(pattern);
- var matches = rgx.Matches(pContent);
- onlineDriv = Convert.ToString(matches[0]);
- onlineDriv = onlineDriv.Remove(onlineDriv.Length - 5);
- textblockOnline.Text = onlineDriv;
-
- if (localDriv != onlineDriv)
- {
- textblockOnline.Foreground = Brushes.Red;
- buttonDL.Visibility = Visibility.Visible;
- }
- else
- textblockOnline.Foreground = Brushes.Green;
- }
-
private void buttonDL_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start(gpuURL);
@@ -232,42 +160,46 @@ namespace EnvyUpdate
}
}
- private void chkPortable_Unchecked(object sender, RoutedEventArgs e)
+ private void chkInstall_Checked(object sender, RoutedEventArgs e)
{
if (chkAutostart != null)
{
chkAutostart.IsEnabled = true;
}
+ if (exepath != appdata)
+ {
+ if (!Directory.Exists(appdata))
+ {
+ Directory.CreateDirectory(appdata);
+ }
+ File.Copy(exeloc, appdata + "EnvyUpdate.exe", true);
+ Util.CreateShortcut("EnvyUpdate", startmenu, appdata + "EnvyUpdate.exe", "Nvidia Updater Application.");
+ }
}
- private void chkPortable_Checked(object sender, RoutedEventArgs e)
+ private void chkInstall_Unchecked(object sender, RoutedEventArgs e)
{
if (chkAutostart != null)
{
chkAutostart.IsEnabled = false;
chkAutostart.IsChecked = false;
}
+ if (Directory.Exists(appdata))
+ {
+ File.Delete(appdata + "EnvyUpdate.exe");
+ File.Delete(startup + "\\EnvyUpdate.lnk");
+ File.Delete(startmenu + "\\EnvyUpdate.lnk");
+ }
}
private void chkAutostart_Checked(object sender, RoutedEventArgs e)
{
- if (exepath != appdata)
- {
- File.Copy(exeloc, appdata + "EnvyUpdate.exe", true);
- Util.CreateShortcut("EnvyUpdate", startup, appdata + "EnvyUpdate.exe", "Nvidia Updater Application.");
- Util.CreateShortcut("EnvyUpdate", startmenu, appdata + "EnvyUpdate.exe", "Nvidia Updater Application.");
- }
- else
- {
- chkAutostart.IsEnabled = false;
- }
+ Util.CreateShortcut("EnvyUpdate", startup, appdata + "EnvyUpdate.exe", "Nvidia Updater Application.");
}
private void chkAutostart_Unchecked(object sender, RoutedEventArgs e)
{
- File.Delete(appdata + "EnvyUpdate.exe");
File.Delete(startup + "\\EnvyUpdate.lnk");
- File.Delete(startmenu + "\\EnvyUpdate.lnk");
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
diff --git a/EnvyUpdate/Properties/AssemblyInfo.cs b/EnvyUpdate/Properties/AssemblyInfo.cs
index 1afbe89..1399985 100644
--- a/EnvyUpdate/Properties/AssemblyInfo.cs
+++ b/EnvyUpdate/Properties/AssemblyInfo.cs
@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EnvyUpdate")]
-[assembly: AssemblyCopyright("Copyright © 2019")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs
index 8d37bdd..1d8aa7b 100644
--- a/EnvyUpdate/Util.cs
+++ b/EnvyUpdate/Util.cs
@@ -196,22 +196,38 @@ namespace EnvyUpdate
}
}
XDocument xDoc = XDocument.Parse(xmlcontent);
+ string gpuName = GetGPUName();
- if (IDtype == "pfid")
+ switch (IDtype)
{
- string gpuName = GetGPUName();
- id = GetValueFromName(xDoc, gpuName);
+ case "psid":
+ id = GetValueFromName(xDoc, gpuName, false);
+ break;
+ case "pfid":
+ id = GetValueFromName(xDoc, gpuName, true);
+ break;
+ case "osid":
+ id = GetOSID();
+ break;
+ case "langid":
+ // Currently unsupported, because Nvidia has a weird way of naming languages in their native OR english version.
+ // https://www.nvidia.com/Download/API/lookupValueSearch.aspx?TypeID=5
+ break;
+ default:
+ break;
}
return id;
}
///
/// Gets Value from Nvidias XML docs by searching for the name. Can be used for OS, Lang and GPU.
+ /// This will produce problems when run on Linux. Good thing Linux has nice package managers to take care of driver updating.
///
///
///
+ ///
///
- private static int GetValueFromName (XDocument xDoc, string query)
+ private static int GetValueFromName (XDocument xDoc, string query, bool psid)
{
int value = 0;
@@ -224,12 +240,20 @@ namespace EnvyUpdate
{
int value1 = 0;
int value2 = 0;
+ string cleanResult = null;
- string result = name.Parent.Value;
- int index = result.IndexOf(sName);
- string cleanResult = (index < 0)
- ? result
- : result.Remove(index, sName.Length);
+ if (psid)
+ {
+ cleanResult = name.Parent.FirstAttribute.Value;
+ }
+ else
+ {
+ string result = name.Parent.Value;
+ int index = result.IndexOf(sName);
+ cleanResult = (index < 0)
+ ? result
+ : result.Remove(index, sName.Length);
+ }
if (i == 0)
{
@@ -254,6 +278,42 @@ namespace EnvyUpdate
return value;
}
///
+ /// Returns hardcoded values for the supported operating systems.
+ ///
+ ///
+ ///
+ private static int GetOSID()
+ {
+ // This is faster than making a whole web request and searching through XML. This application only supports 8 possible IDs, so they are hardcoded.
+ int value = 0;
+ string OS = Environment.OSVersion.Version.Major.ToString() + "." + Environment.OSVersion.Version.Minor.ToString();
+
+ // Here the 32bit values are used. Later, if the OS is 64bit, we'll add 1, since that is how Nvidia does their IDs.
+ switch (OS)
+ {
+ case "10.0":
+ value = 56;
+ break;
+ case "6.1":
+ value = 18;
+ break;
+ case "6.2":
+ value = 27;
+ break;
+ case "6.3":
+ value = 40;
+ break;
+ default:
+ break;
+ }
+
+ //Simply increment the ID by 1 if OS is 64bit.
+ if (Environment.Is64BitOperatingSystem)
+ value++;
+
+ return value;
+ }
+ ///
/// Returns GPU name in lower case.
///
///
diff --git a/EnvyUpdate/app.manifest b/EnvyUpdate/app.manifest
new file mode 100644
index 0000000..d9bbc1e
--- /dev/null
+++ b/EnvyUpdate/app.manifest
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xmltest/.vscode/launch.json b/xmltest/.vscode/launch.json
deleted file mode 100644
index f83c818..0000000
--- a/xmltest/.vscode/launch.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- // Use IntelliSense to learn about possible attributes.
- // Hover to view descriptions of existing attributes.
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
- "version": "0.2.0",
- "configurations": [
- {
- "name": ".NET Core Launch (console)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/xmltest.dll",
- "args": [],
- "cwd": "${workspaceFolder}",
- "console": "internalConsole",
- "stopAtEntry": false
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach",
- "processId": "${command:pickProcess}"
- }
- ]
-}
\ No newline at end of file
diff --git a/xmltest/.vscode/tasks.json b/xmltest/.vscode/tasks.json
deleted file mode 100644
index 99e21ea..0000000
--- a/xmltest/.vscode/tasks.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/xmltest.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "publish",
- "command": "dotnet",
- "type": "process",
- "args": [
- "publish",
- "${workspaceFolder}/xmltest.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "${workspaceFolder}/xmltest.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ No newline at end of file
diff --git a/xmltest/Program.cs b/xmltest/Program.cs
deleted file mode 100644
index eb289e5..0000000
--- a/xmltest/Program.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.IO;
-using System.Xml;
-using System.Xml.Linq;
-using System.Net;
-using System.Linq;
-
-
-namespace xmltest
-{
- class Program
- {
- static void Main(string[] args)
- {
- string xmlcontent = null;
-
- using (var wc = new WebClient())
- {
- xmlcontent = wc.DownloadString("https://www.nvidia.com/Download/API/lookupValueSearch.aspx?TypeID=3");
- }
- var xDoc = XDocument.Parse(xmlcontent);
-
- var names = xDoc.Descendants("Name");
- foreach (var name in names)
- {
- string sname = name.Value.ToString();
- if (sname == "GeForce RTX 2080")
- {
- string value = name.Parent.Value;
- int index = value.IndexOf(sname);
- string cleanValue = (index < 0)
- ? value
- : value.Remove(index, sname.Length);
-
- Console.WriteLine(cleanValue);
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/xmltest/xmltest.csproj b/xmltest/xmltest.csproj
deleted file mode 100644
index c73e0d1..0000000
--- a/xmltest/xmltest.csproj
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- Exe
- netcoreapp3.1
-
-
-