Skip to content

Commit f1b10c4

Browse files
committed
Added support for creating desktop shortcuts
1 parent 6790de5 commit f1b10c4

File tree

8 files changed

+108
-12
lines changed

8 files changed

+108
-12
lines changed

PatchMyPath/FormHome.Designer.cs

Lines changed: 15 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PatchMyPath/FormHome.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using IWshRuntimeLibrary;
2+
using Microsoft.VisualBasic;
13
using NLog;
24
using PatchMyPath.Config;
35
using PatchMyPath.Properties;
@@ -7,7 +9,9 @@
79
using System.Diagnostics;
810
using System.IO;
911
using System.Linq;
12+
using System.Runtime.InteropServices.ComTypes;
1013
using System.Windows.Forms;
14+
using File = System.IO.File;
1115

1216
namespace PatchMyPath
1317
{
@@ -202,6 +206,35 @@ private void OpenFileExplorer_Click(object sender, EventArgs e)
202206
}
203207
}
204208

209+
private void AddShortcut_Click(object sender, EventArgs e)
210+
{
211+
if (InstallsListBox.SelectedItem is Install install)
212+
{
213+
if (!install.IsLegal || install.Type == Launch.Invalid)
214+
{
215+
return;
216+
}
217+
218+
string input = Interaction.InputBox(Resources.ShortcutCreate, Resources.ShortcutCreateTitle);
219+
220+
if (string.IsNullOrWhiteSpace(input))
221+
{
222+
return;
223+
}
224+
225+
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{input}.lnk");
226+
227+
WshShell shell = new WshShell();
228+
229+
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(path);
230+
shortcut.TargetPath = Application.ExecutablePath;
231+
shortcut.IconLocation = $"{install.Executable},0";
232+
shortcut.Arguments = $"--launch \"{install.GamePath}\"";
233+
shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
234+
shortcut.Save();
235+
}
236+
}
237+
205238
#endregion
206239

207240
#region Duplicator Tool

PatchMyPath/FormHome.es.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,7 @@
174174
<data name="SettingsToolStripMenuItem.Text" xml:space="preserve">
175175
<value>Configuracion</value>
176176
</data>
177+
<data name="AddShortcut.Text" xml:space="preserve">
178+
<value>Añadir Acceso Directo en el Escritorio</value>
179+
</data>
177180
</root>

PatchMyPath/FormHome.resx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,25 @@
150150
<value>Epic Games Store</value>
151151
</data>
152152
<data name="StartAsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
153-
<value>187, 22</value>
153+
<value>206, 22</value>
154154
</data>
155155
<data name="StartAsToolStripMenuItem.Text" xml:space="preserve">
156156
<value>Start with</value>
157157
</data>
158158
<data name="OpenFileExplorer.Size" type="System.Drawing.Size, System.Drawing">
159-
<value>187, 22</value>
159+
<value>206, 22</value>
160160
</data>
161161
<data name="OpenFileExplorer.Text" xml:space="preserve">
162162
<value>Open on File Explorer</value>
163163
</data>
164+
<data name="AddShortcut.Size" type="System.Drawing.Size, System.Drawing">
165+
<value>206, 22</value>
166+
</data>
167+
<data name="AddShortcut.Text" xml:space="preserve">
168+
<value>Add shortcut on Desktop</value>
169+
</data>
164170
<data name="InstallContextMenuStrip.Size" type="System.Drawing.Size, System.Drawing">
165-
<value>188, 70</value>
171+
<value>207, 92</value>
166172
</data>
167173
<data name="&gt;&gt;InstallContextMenuStrip.Name" xml:space="preserve">
168174
<value>InstallContextMenuStrip</value>
@@ -1406,6 +1412,12 @@
14061412
<data name="&gt;&gt;EGLToolStripMenuItem.Type" xml:space="preserve">
14071413
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
14081414
</data>
1415+
<data name="&gt;&gt;OpenFileExplorer.Name" xml:space="preserve">
1416+
<value>OpenFileExplorer</value>
1417+
</data>
1418+
<data name="&gt;&gt;OpenFileExplorer.Type" xml:space="preserve">
1419+
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
1420+
</data>
14091421
<data name="&gt;&gt;FolderBrowser.Name" xml:space="preserve">
14101422
<value>FolderBrowser</value>
14111423
</data>
@@ -1448,10 +1460,10 @@
14481460
<data name="&gt;&gt;LogToolStripStatusLabel.Type" xml:space="preserve">
14491461
<value>System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
14501462
</data>
1451-
<data name="&gt;&gt;OpenFileExplorer.Name" xml:space="preserve">
1452-
<value>OpenFileExplorer</value>
1463+
<data name="&gt;&gt;AddShortcut.Name" xml:space="preserve">
1464+
<value>AddShortcut</value>
14531465
</data>
1454-
<data name="&gt;&gt;OpenFileExplorer.Type" xml:space="preserve">
1466+
<data name="&gt;&gt;AddShortcut.Type" xml:space="preserve">
14551467
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
14561468
</data>
14571469
<data name="&gt;&gt;$this.Name" xml:space="preserve">

PatchMyPath/PatchMyPath.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
<Reference Include="Microsoft.CSharp" />
2424
<Reference Include="Microsoft.VisualBasic" />
2525
<Reference Include="System.Windows.Forms" />
26+
<COMReference Include="IWshRuntimeLibrary">
27+
<WrapperTool>tlbimp</WrapperTool>
28+
<VersionMinor>0</VersionMinor>
29+
<VersionMajor>1</VersionMajor>
30+
<Guid>f935dc20-1cf0-11d0-adb9-00c04fd58a0b</Guid>
31+
<Lcid>0</Lcid>
32+
<Isolated>false</Isolated>
33+
<EmbedInteropTypes>true</EmbedInteropTypes>
34+
</COMReference>
2635
<Compile Update="Properties\Resources.Designer.cs">
2736
<DesignTime>True</DesignTime>
2837
<AutoGen>True</AutoGen>

PatchMyPath/Properties/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PatchMyPath/Properties/Resources.es.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,10 @@ Puedes leer la Politica de privacidad en https://justalemon.ml/Privacy_policy</v
287287
<data name="CLINotLegalTitle" xml:space="preserve">
288288
<value>Instalación Manipulada</value>
289289
</data>
290+
<data name="ShortcutCreate" xml:space="preserve">
291+
<value>Introduzca el nombre deseado para el acceso directo</value>
292+
</data>
293+
<data name="ShortcutCreateTitle" xml:space="preserve">
294+
<value>Nombre del Acceso Directo</value>
295+
</data>
290296
</root>

PatchMyPath/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,4 +450,10 @@ You can read the Privacy policy on https://justalemon.ml/Privacy_policy</value>
450450
<data name="CLINotLegalTitle" xml:space="preserve">
451451
<value>Tampered Installation</value>
452452
</data>
453+
<data name="ShortcutCreate" xml:space="preserve">
454+
<value>Enter the desired name of the shortcut</value>
455+
</data>
456+
<data name="ShortcutCreateTitle" xml:space="preserve">
457+
<value>Enter Shortcut Name</value>
458+
</data>
453459
</root>

0 commit comments

Comments
 (0)