working towards 2.0
add better version detection add new licenses working on automatic GPU, lang and os detection add debug mode for non-nivida
This commit is contained in:
parent
5580669497
commit
bf9814cfd0
9 changed files with 212 additions and 25 deletions
|
@ -7,10 +7,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnvyUpdate", "EnvyUpdate\En
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug - ignoregpu|Any CPU = Debug - ignoregpu|Any CPU
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug - ignoregpu|Any CPU.ActiveCfg = Debug - ignoregpu|Any CPU
|
||||||
|
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug - ignoregpu|Any CPU.Build.0 = Debug - ignoregpu|Any CPU
|
||||||
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1BF2468D-9579-462D-9153-4836E9C8721F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1BF2468D-9579-462D-9153-4836E9C8721F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1BF2468D-9579-462D-9153-4836E9C8721F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
|
|
@ -43,6 +43,17 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>false</SignAssembly>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug - ignoregpu|AnyCPU'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<LangVersion>7.3</LangVersion>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
|
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
|
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
|
||||||
|
@ -50,12 +61,16 @@
|
||||||
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
|
<HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Notifications.Wpf, Version=0.1.1.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Notifications.Wpf, Version=0.1.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Notifications.Wpf.0.1.1\lib\net461\Notifications.Wpf.dll</HintPath>
|
<HintPath>..\packages\Notifications.Wpf.0.1.1\lib\net461\Notifications.Wpf.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Management" />
|
<Reference Include="System.Management" />
|
||||||
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -74,6 +89,7 @@
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="GlobalVars.cs" />
|
||||||
<Compile Include="InfoWindow.xaml.cs">
|
<Compile Include="InfoWindow.xaml.cs">
|
||||||
<DependentUpon>InfoWindow.xaml</DependentUpon>
|
<DependentUpon>InfoWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
14
EnvyUpdate/GlobalVars.cs
Normal file
14
EnvyUpdate/GlobalVars.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EnvyUpdate
|
||||||
|
{
|
||||||
|
class GlobalVars
|
||||||
|
{
|
||||||
|
public static string gpuName = null;
|
||||||
|
public static bool mobile = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:EnvyUpdate"
|
xmlns:local="clr-namespace:EnvyUpdate"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="InfoWindow" Height="224.547" Width="285.714">
|
Title="InfoWindow" Height="238.853" Width="285.714">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Button Content="How to use this application?" Margin="10,10,10,0" VerticalAlignment="Top" Height="45" Click="Button_Click"/>
|
<Button Content="How to use this application?" Margin="10,10,10,0" VerticalAlignment="Top" Height="45" Click="Button_Click"/>
|
||||||
<Label Content="Licenses:" HorizontalAlignment="Left" Margin="10,60,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
<Label Content="Licenses:" HorizontalAlignment="Left" Margin="10,60,0,0" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||||
|
@ -13,7 +13,8 @@
|
||||||
<TextBlock x:Name="textFody" Margin="10,109,10,0" TextWrapping="Wrap" Text="Fody: MIT" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textFody_MouseDown"/>
|
<TextBlock x:Name="textFody" Margin="10,109,10,0" TextWrapping="Wrap" Text="Fody: MIT" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textFody_MouseDown"/>
|
||||||
<TextBlock x:Name="textNotifyIcon" Margin="10,127,10,0" TextWrapping="Wrap" Text="wpf-notifyicon: CPOL" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textNotifyIcon_MouseDown"/>
|
<TextBlock x:Name="textNotifyIcon" Margin="10,127,10,0" TextWrapping="Wrap" Text="wpf-notifyicon: CPOL" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textNotifyIcon_MouseDown"/>
|
||||||
<TextBlock x:Name="textNotifications" Margin="10,145,10,0" TextWrapping="Wrap" Text="Notifications.Wpf: MIT" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textNotifications_MouseDown"/>
|
<TextBlock x:Name="textNotifications" Margin="10,145,10,0" TextWrapping="Wrap" Text="Notifications.Wpf: MIT" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textNotifications_MouseDown"/>
|
||||||
<TextBlock Margin="10,163,10,0" TextWrapping="Wrap" Text="Icon made by Freepik from www.flaticon.com" Height="18" VerticalAlignment="Top"/>
|
<TextBlock Margin="10,181,10,0" TextWrapping="Wrap" Text="Icon made by Freepik from www.flaticon.com" Height="18" VerticalAlignment="Top"/>
|
||||||
|
<TextBlock x:Name="textNewtonsoft" Margin="10,163,10,0" TextWrapping="Wrap" Height="18" VerticalAlignment="Top" MouseEnter="text_MouseEnter" MouseLeave="text_MouseLeave" MouseDown="textNewtonsoft_MouseDown"><Run Text="Newtonsoft.Json"/><Run Text=": MIT"/></TextBlock>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
@ -47,5 +47,9 @@ namespace EnvyUpdate
|
||||||
{
|
{
|
||||||
System.Diagnostics.Process.Start("https://github.com/Federerer/Notifications.Wpf/blob/master/LICENSE");
|
System.Diagnostics.Process.Start("https://github.com/Federerer/Notifications.Wpf/blob/master/LICENSE");
|
||||||
}
|
}
|
||||||
|
private void textNewtonsoft_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Process.Start("https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,25 @@ namespace EnvyUpdate
|
||||||
private readonly string exepath = Path.GetDirectoryName(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 startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
|
||||||
private readonly string version = "1.4";
|
private readonly string version = "1.4";
|
||||||
|
private string argument = null;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Title += " " + version;
|
Title += " " + version;
|
||||||
|
|
||||||
|
// Try to get command line arguments
|
||||||
|
try
|
||||||
|
{
|
||||||
|
argument = Environment.GetCommandLineArgs()[1];
|
||||||
|
Console.WriteLine("Starting in debug mode.");
|
||||||
|
}
|
||||||
|
catch (IndexOutOfRangeException)
|
||||||
|
{
|
||||||
|
// This is necessary, since .NET throws an exception if you check for a non-existant arg.
|
||||||
|
Console.WriteLine("Starting in release mode.");
|
||||||
|
}
|
||||||
|
|
||||||
// Check if EnvyUpdate is already running
|
// Check if EnvyUpdate is already running
|
||||||
if (Util.IsInstanceOpen("EnvyUpdate"))
|
if (Util.IsInstanceOpen("EnvyUpdate"))
|
||||||
{
|
{
|
||||||
|
@ -50,16 +63,9 @@ namespace EnvyUpdate
|
||||||
}
|
}
|
||||||
catch (WebException)
|
catch (WebException)
|
||||||
{
|
{
|
||||||
//Silently fail.
|
// Silently fail.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (Environment.GetCommandLineArgs()[1] == "--ignore-gpu")
|
|
||||||
{
|
|
||||||
MessageBox.Show("Skipping GPU check!");
|
|
||||||
textblockGPU.Text = "Check skipped.";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (Util.GetLocDriv() != null)
|
if (Util.GetLocDriv() != null)
|
||||||
{
|
{
|
||||||
localDriv = Util.GetLocDriv();
|
localDriv = Util.GetLocDriv();
|
||||||
|
@ -67,8 +73,16 @@ namespace EnvyUpdate
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
switch (argument)
|
||||||
|
{
|
||||||
|
case "/ignoregpu":
|
||||||
|
MessageBox.Show("Debug: GPU ignored.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
MessageBox.Show("No NVIDIA GPU found. Application will exit.");
|
MessageBox.Show("No NVIDIA GPU found. Application will exit.");
|
||||||
Environment.Exit(255);
|
Environment.Exit(255);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File.Exists(appdata + "nvidia-update.txt"))
|
if (File.Exists(appdata + "nvidia-update.txt"))
|
||||||
|
@ -129,7 +143,7 @@ namespace EnvyUpdate
|
||||||
pfid = Util.GetData(f.FullName, "ProductType");
|
pfid = Util.GetData(f.FullName, "ProductType");
|
||||||
osid = Util.GetData(f.FullName, "OperatingSystem");
|
osid = Util.GetData(f.FullName, "OperatingSystem");
|
||||||
langid = Util.GetData(f.FullName, "Language");
|
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";
|
gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&osid=" + osid.ToString() + "&lid=" + langid.ToString();
|
||||||
WebClient c = new WebClient();
|
WebClient c = new WebClient();
|
||||||
gpuURL = c.DownloadString(gpuURL);
|
gpuURL = c.DownloadString(gpuURL);
|
||||||
string pContent = c.DownloadString(gpuURL);
|
string pContent = c.DownloadString(gpuURL);
|
||||||
|
@ -178,16 +192,18 @@ namespace EnvyUpdate
|
||||||
osid = Util.GetData(f.FullName, "OperatingSystem");
|
osid = Util.GetData(f.FullName, "OperatingSystem");
|
||||||
langid = Util.GetData(f.FullName, "Language");
|
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";
|
gpuURL = "http://www.nvidia.com/Download/processDriver.aspx?psid=" + psid.ToString() + "&pfid=" + pfid.ToString() + "&rpf=1&osid=" + osid.ToString() + "&lid=" + langid.ToString() + "&ctk=0";
|
||||||
WebClient c = new WebClient();
|
string pContent = null;
|
||||||
|
using (WebClient c = new WebClient())
|
||||||
|
{
|
||||||
gpuURL = c.DownloadString(gpuURL);
|
gpuURL = c.DownloadString(gpuURL);
|
||||||
string pContent = c.DownloadString(gpuURL);
|
pContent = c.DownloadString(gpuURL);
|
||||||
|
}
|
||||||
var pattern = @"\d{3}\.\d{2} ";
|
var pattern = @"\d{3}\.\d{2} ";
|
||||||
Regex rgx = new Regex(pattern);
|
Regex rgx = new Regex(pattern);
|
||||||
var matches = rgx.Matches(pContent);
|
var matches = rgx.Matches(pContent);
|
||||||
onlineDriv = Convert.ToString(matches[0]);
|
onlineDriv = Convert.ToString(matches[0]);
|
||||||
onlineDriv = onlineDriv.Remove(onlineDriv.Length - 5);
|
onlineDriv = onlineDriv.Remove(onlineDriv.Length - 5);
|
||||||
textblockOnline.Text = onlineDriv;
|
textblockOnline.Text = onlineDriv;
|
||||||
c.Dispose();
|
|
||||||
|
|
||||||
if (localDriv != onlineDriv)
|
if (localDriv != onlineDriv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,9 @@ using System.Linq;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace EnvyUpdate
|
namespace EnvyUpdate
|
||||||
{
|
{
|
||||||
|
@ -79,7 +82,8 @@ namespace EnvyUpdate
|
||||||
/// <param name="description"></param>
|
/// <param name="description"></param>
|
||||||
public static void CreateShortcut(string shortcutName, string shortcutPath, string targetFileLocation, string description)
|
public static void CreateShortcut(string shortcutName, string shortcutPath, string targetFileLocation, string description)
|
||||||
{
|
{
|
||||||
string shortcutLocation = System.IO.Path.Combine(shortcutPath, shortcutName + ".lnk");
|
// It seems unnecessarily complex to create a simple shortcut using C#. Oh well.
|
||||||
|
string shortcutLocation = Path.Combine(shortcutPath, shortcutName + ".lnk");
|
||||||
WshShell shell = new WshShell();
|
WshShell shell = new WshShell();
|
||||||
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);
|
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);
|
||||||
|
|
||||||
|
@ -87,9 +91,15 @@ namespace EnvyUpdate
|
||||||
shortcut.TargetPath = targetFileLocation;
|
shortcut.TargetPath = targetFileLocation;
|
||||||
shortcut.Save();
|
shortcut.Save();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if application is already running.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static bool IsInstanceOpen(string name)
|
public static bool IsInstanceOpen(string name)
|
||||||
{
|
{
|
||||||
|
// This basically counts the processes named like the supplied string. If the count is more than 0, it will return true.
|
||||||
|
// Let's hope nobody manages to open this application 2,147,483,647 times, because then the int would overflow and crash EnvyUpdate. But I suppose you've got worse problems than that if you've got 2,147,483,647 instances of any process.
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (Process clsProcess in Process.GetProcesses())
|
foreach (Process clsProcess in Process.GetProcesses())
|
||||||
{
|
{
|
||||||
|
@ -104,21 +114,31 @@ namespace EnvyUpdate
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Shows main window and restores WindowState
|
||||||
|
/// </summary>
|
||||||
public static void ShowMain()
|
public static void ShowMain()
|
||||||
{
|
{
|
||||||
Application.Current.MainWindow.Show();
|
Application.Current.MainWindow.Show();
|
||||||
Application.Current.MainWindow.WindowState = WindowState.Normal;
|
Application.Current.MainWindow.WindowState = WindowState.Normal;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Checks for newest EnvyUpdate version.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public static string GetNewVer()
|
public static string GetNewVer()
|
||||||
{
|
{
|
||||||
string updPath = "https://raw.githubusercontent.com/fyr77/EnvyUpdate/master/res/version.txt";
|
// This will fetch the most recent version's tag on GitHub.
|
||||||
|
string updPath = "https://api.github.com/repos/fyr77/envyupdate/releases/latest";
|
||||||
|
|
||||||
WebClient wc = new WebClient();
|
WebClient wc = new WebClient();
|
||||||
string webData = wc.DownloadString(updPath).Truncate(3);
|
// Use some user agent to not get 403'd by GitHub.
|
||||||
|
wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko");
|
||||||
|
string webData = wc.DownloadString(updPath);
|
||||||
|
dynamic data = JsonConvert.DeserializeObject(webData);
|
||||||
|
string version = data.tag_name;
|
||||||
|
|
||||||
return webData;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -135,7 +155,9 @@ namespace EnvyUpdate
|
||||||
|
|
||||||
MessageBox.Show("New version of EnvyUpdate found. Application will restart.\nThis will probably take a few seconds.");
|
MessageBox.Show("New version of EnvyUpdate found. Application will restart.\nThis will probably take a few seconds.");
|
||||||
|
|
||||||
// Replace exe with new one
|
// Replace exe with new one.
|
||||||
|
// This starts a seperate cmd process which will wait a bit, then delete EnvyUpdate and rename the previously downloaded EnvyUpdated.exe to EnvyUpdate.exe
|
||||||
|
// I know this is a bit dumb, but I honestly couldn't think of a different way to solve this properly, since the Application would need to delete itself.
|
||||||
Process process = new Process();
|
Process process = new Process();
|
||||||
ProcessStartInfo startInfo = new ProcessStartInfo
|
ProcessStartInfo startInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
|
@ -149,5 +171,114 @@ namespace EnvyUpdate
|
||||||
|
|
||||||
Environment.Exit(2);
|
Environment.Exit(2);
|
||||||
}
|
}
|
||||||
|
public static int GetIDs(string IDtype)
|
||||||
|
{
|
||||||
|
// TODO: check for 2 occurences of GPU - if yes ask if mobile!!!
|
||||||
|
string xmlcontent = null;
|
||||||
|
int id = -1;
|
||||||
|
|
||||||
|
using (var wc = new WebClient())
|
||||||
|
{
|
||||||
|
switch (IDtype)
|
||||||
|
{
|
||||||
|
case "psid":
|
||||||
|
case "pfid":
|
||||||
|
xmlcontent = wc.DownloadString("https://www.nvidia.com/Download/API/lookupValueSearch.aspx?TypeID=3");
|
||||||
|
break;
|
||||||
|
case "osid":
|
||||||
|
xmlcontent = wc.DownloadString("https://www.nvidia.com/Download/API/lookupValueSearch.aspx?TypeID=4");
|
||||||
|
break;
|
||||||
|
case "langid":
|
||||||
|
xmlcontent = wc.DownloadString("https://www.nvidia.com/Download/API/lookupValueSearch.aspx?TypeID=5");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XDocument xDoc = XDocument.Parse(xmlcontent);
|
||||||
|
|
||||||
|
if (IDtype == "pfid")
|
||||||
|
{
|
||||||
|
string gpuName = GetGPUName();
|
||||||
|
id = GetValueFromName(xDoc, gpuName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Gets Value from Nvidias XML docs by searching for the name. Can be used for OS, Lang and GPU.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xDoc"></param>
|
||||||
|
/// <param name="query"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static int GetValueFromName (XDocument xDoc, string query)
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
|
||||||
|
var names = xDoc.Descendants("Name");
|
||||||
|
foreach (var name in names)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
string sName = name.Value.ToString().ToLower();
|
||||||
|
if (sName == query)
|
||||||
|
{
|
||||||
|
int value1 = 0;
|
||||||
|
int value2 = 0;
|
||||||
|
|
||||||
|
string result = name.Parent.Value;
|
||||||
|
int index = result.IndexOf(sName);
|
||||||
|
string cleanResult = (index < 0)
|
||||||
|
? result
|
||||||
|
: result.Remove(index, sName.Length);
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
value1 = int.Parse(cleanResult);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value2 = int.Parse(cleanResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = value1;
|
||||||
|
|
||||||
|
if (GlobalVars.mobile)
|
||||||
|
{
|
||||||
|
value = value2;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns GPU name in lower case.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string GetGPUName()
|
||||||
|
{
|
||||||
|
string GPUName = null;
|
||||||
|
foreach (ManagementObject obj in new ManagementObjectSearcher("SELECT * FROM Win32_VideoController").Get())
|
||||||
|
{
|
||||||
|
if (obj["Description"].ToString().ToLower().Contains("radeon"))
|
||||||
|
{
|
||||||
|
// If it's an AMD card, use the "Name" field, because they use chip code numbers in "VideoProcessor", which we do not need.
|
||||||
|
// Todo for 3.0: Find a way to ignore mobile Radeon GPUs in Laptops.
|
||||||
|
// For now: Since we only care about Nvidia GPUs, don't break even if an AMD card is found.
|
||||||
|
GPUName = obj["Name"].ToString().ToLower();
|
||||||
|
//break;
|
||||||
|
}
|
||||||
|
if (obj["Description"].ToString().ToLower().Contains("nvidia"))
|
||||||
|
{
|
||||||
|
// If it's an Nvidia GPU, use VideoProcessor so we don't have to truncate the resulting string.
|
||||||
|
GPUName = obj["VideoProcessor"].ToString().ToLower();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// This should NEVER return null outside of debugging mode, since EnvyUpdate should refuse to start without and Nvidia GPU.
|
||||||
|
return GPUName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,5 +3,6 @@
|
||||||
<package id="Costura.Fody" version="4.1.0" targetFramework="net472" />
|
<package id="Costura.Fody" version="4.1.0" targetFramework="net472" />
|
||||||
<package id="Fody" version="6.2.0" targetFramework="net472" developmentDependency="true" />
|
<package id="Fody" version="6.2.0" targetFramework="net472" developmentDependency="true" />
|
||||||
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net472" />
|
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net472" />
|
||||||
|
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
|
||||||
<package id="Notifications.Wpf" version="0.1.1" targetFramework="net472" />
|
<package id="Notifications.Wpf" version="0.1.1" targetFramework="net472" />
|
||||||
</packages>
|
</packages>
|
|
@ -32,4 +32,5 @@ The application is compatible with all Nvidia GPUs that have their drivers avail
|
||||||
* Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Fody/blob/master/License.txt)
|
* Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Fody/blob/master/License.txt)
|
||||||
* wpf-notifyicon (for showing an icon in the system tray): [CPOL](https://github.com/hardcodet/wpf-notifyicon/blob/master/LICENSE)
|
* wpf-notifyicon (for showing an icon in the system tray): [CPOL](https://github.com/hardcodet/wpf-notifyicon/blob/master/LICENSE)
|
||||||
* Notifications.Wpf: [MIT](https://github.com/Federerer/Notifications.Wpf/blob/master/LICENSE)
|
* Notifications.Wpf: [MIT](https://github.com/Federerer/Notifications.Wpf/blob/master/LICENSE)
|
||||||
|
* Newtonsoft.Json: [MIT](https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md)
|
||||||
* Icon made by Freepik from www.flaticon.com
|
* Icon made by Freepik from www.flaticon.com
|
||||||
|
|
Reference in a new issue