diff --git a/DS4Windows/DS4Forms/WinProgs.cs b/DS4Windows/DS4Forms/WinProgs.cs
index 232ed85..4cd40ad 100644
--- a/DS4Windows/DS4Forms/WinProgs.cs
+++ b/DS4Windows/DS4Forms/WinProgs.cs
@@ -7,6 +7,9 @@ using System.IO;
using System.Xml;
using System.Runtime.InteropServices;
+using System.Threading;
+using System.Diagnostics;
+using System.Threading.Tasks;
namespace DS4Windows
{
@@ -384,7 +387,7 @@ namespace DS4Windows
bnAddPrograms.Text = Properties.Resources.Loading;
bnAddPrograms.Enabled = false;
cMSPrograms.Items.Remove(addSteamGamesToolStripMenuItem);
- await System.Threading.Tasks.Task.Run(() => GetApps(steamgamesdir));
+ await Task.Run(() => GetApps(steamgamesdir));
addLoadedApps();
}
@@ -395,7 +398,7 @@ namespace DS4Windows
{
bnAddPrograms.Text = Properties.Resources.Loading;
bnAddPrograms.Enabled = false;
- await System.Threading.Tasks.Task.Run(() => GetApps(fbd.SelectedPath));
+ await Task.Run(() => GetApps(fbd.SelectedPath));
addLoadedApps();
}
}
@@ -423,7 +426,7 @@ namespace DS4Windows
bnAddPrograms.Text = Properties.Resources.Loading;
bnAddPrograms.Enabled = false;
cMSPrograms.Items.Remove(addOriginGamesToolStripMenuItem);
- await System.Threading.Tasks.Task.Run(() => GetApps(origingamesdir));
+ await Task.Run(() => GetApps(origingamesdir));
addLoadedApps();
}
@@ -432,7 +435,7 @@ namespace DS4Windows
bnAddPrograms.Text = Properties.Resources.Loading;
bnAddPrograms.Enabled = false;
cMSPrograms.Items.Remove(addProgramsFromStartMenuToolStripMenuItem);
- await System.Threading.Tasks.Task.Run(() => GetShortcuts(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs"));
+ await Task.Run(() => GetShortcuts(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs"));
addLoadedApps();
}
@@ -474,35 +477,57 @@ namespace DS4Windows
public static string ResolveShortcut(string filePath)
{
// IWshRuntimeLibrary is in the COM library "Windows Script Host Object Model"
- IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
+ //IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
+ Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")); // Windows Script Host Shell Object
+ dynamic shell = Activator.CreateInstance(t);
+ string result;
try
{
- IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
- return shortcut.TargetPath;
+ //IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
+ var shortcut = shell.CreateShortcut(filePath);
+ result = shortcut.TargetPath;
+ Marshal.FinalReleaseComObject(shortcut);
}
catch (COMException)
{
// A COMException is thrown if the file is not a valid shortcut (.lnk) file
- return null;
+ result = null;
}
+ finally
+ {
+ Marshal.FinalReleaseComObject(shell);
+ }
+
+ return result;
}
public static string ResolveShortcutAndArgument(string filePath)
{
// IWshRuntimeLibrary is in the COM library "Windows Script Host Object Model"
- IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
+ //IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
+ Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")); // Windows Script Host Shell Object
+ dynamic shell = Activator.CreateInstance(t);
+ string result;
try
{
- IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
- return shortcut.TargetPath + " " + shortcut.Arguments;
+ //IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
+ var shortcut = shell.CreateShortcut(filePath);
+ result = shortcut.TargetPath + " " + shortcut.Arguments;
+ Marshal.FinalReleaseComObject(shortcut);
}
catch (COMException)
{
// A COMException is thrown if the file is not a valid shortcut (.lnk) file
- return null;
+ result = null;
}
+ finally
+ {
+ Marshal.FinalReleaseComObject(shell);
+ }
+
+ return result;
}
private void cBTurnOffDS4W_CheckedChanged(object sender, EventArgs e)
diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj
index 3cf1509..b7cc09c 100644
--- a/DS4Windows/DS4Windows.csproj
+++ b/DS4Windows/DS4Windows.csproj
@@ -1116,17 +1116,6 @@
-
-
- {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}
- 1
- 0
- 0
- tlbimp
- False
- True
-
-