-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixup installer and shortcut creation
- Loading branch information
Showing
2 changed files
with
93 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace TerraAngel.Installer; | ||
|
||
internal class WindowsShortcutUtility | ||
{ | ||
public static void CreateShortcut(string targetApp, string workingDirectory, string outputFile) | ||
{ | ||
IShellLink link = (IShellLink)new ShellLink(); | ||
|
||
link.SetPath(targetApp); | ||
link.SetWorkingDirectory(workingDirectory); | ||
|
||
IPersistFile file = (IPersistFile)link; | ||
file.Save(outputFile, false); | ||
} | ||
|
||
[ComImport] | ||
[Guid("00021401-0000-0000-C000-000000000046")] | ||
private class ShellLink | ||
{ | ||
|
||
} | ||
|
||
[ComImport] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
[Guid("000214F9-0000-0000-C000-000000000046")] | ||
private interface IShellLink | ||
{ | ||
void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, out IntPtr pfd, int fFlags); | ||
void GetIDList(out IntPtr ppidl); | ||
void SetIDList(IntPtr pidl); | ||
void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName); | ||
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName); | ||
void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath); | ||
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir); | ||
void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath); | ||
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs); | ||
void GetHotkey(out short pwHotkey); | ||
void SetHotkey(short wHotkey); | ||
void GetShowCmd(out int piShowCmd); | ||
void SetShowCmd(int iShowCmd); | ||
void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath, out int piIcon); | ||
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon); | ||
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved); | ||
void Resolve(IntPtr hwnd, int fFlags); | ||
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile); | ||
} | ||
|
||
[ComImport()] | ||
[Guid("0000010B-0000-0000-C000-000000000046")] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
private interface IPersistFile | ||
{ | ||
[PreserveSig] | ||
int GetClassID(out Guid pClassID); | ||
|
||
[PreserveSig] | ||
int IsDirty(); | ||
|
||
void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, uint dwMode); | ||
|
||
void Save([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [MarshalAs(UnmanagedType.Bool)] bool fRemember); | ||
|
||
void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] string pszFileName); | ||
|
||
void GetCurFile([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszFileName); | ||
} | ||
} |