-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script to support desktop shortcut creation for portable distributions
- Loading branch information
1 parent
cbf646e
commit b28468e
Showing
5 changed files
with
109 additions
and
15 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
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,89 @@ | ||
/* | ||
* "GEDKeeper", the personal genealogical database editor. | ||
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih. | ||
* | ||
* This file is part of "GEDKeeper". | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#if OS_MSWIN | ||
|
||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.InteropServices.ComTypes; | ||
using System.Text; | ||
using GKCore; | ||
|
||
namespace GKUI.Platform | ||
{ | ||
/// <summary> | ||
/// For portable distributions. | ||
/// </summary> | ||
public class ShellLinkTool | ||
{ | ||
public static bool HasArg(string[] args) | ||
{ | ||
return Array.IndexOf(args, "--createshortcut") >= 0; | ||
} | ||
|
||
public static void CreateShortcut() | ||
{ | ||
var exeName = GKUtils.GetBinPath() + "GEDKeeper3.exe"; | ||
|
||
IShellLink link = (IShellLink)new ShellLink(); | ||
link.SetPath(exeName); | ||
|
||
var file = (IPersistFile)link; | ||
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); | ||
file.Save(Path.Combine(desktopPath, "GEDKeeper3.lnk"), false); | ||
} | ||
} | ||
|
||
|
||
[ComImport] | ||
[Guid("00021401-0000-0000-C000-000000000046")] | ||
internal class ShellLink | ||
{ | ||
} | ||
|
||
|
||
[ComImport] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
[Guid("000214F9-0000-0000-C000-000000000046")] | ||
internal 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); | ||
} | ||
} | ||
|
||
#endif |
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