-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa5773d
commit 7135d49
Showing
8 changed files
with
136 additions
and
31 deletions.
There are no files selected for viewing
Binary file not shown.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.InteropServices.ComTypes; | ||
|
||
namespace DuckDNS | ||
{ | ||
class WShellLink | ||
{ | ||
public static void CreateLink(string name, string description, string path) | ||
{ | ||
IShellLink link = (IShellLink)new ShellLink(); | ||
|
||
// setup shortcut information | ||
link.SetDescription(description); | ||
link.SetPath(path); | ||
|
||
// save it | ||
IPersistFile file = (IPersistFile)link; | ||
file.Save(name, false); | ||
} | ||
} | ||
|
||
[ComImport] | ||
[Guid("00021401-0000-0000-C000-000000000046")] | ||
class ShellLink | ||
{ | ||
} | ||
|
||
[ComImport] | ||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | ||
[Guid("000214F9-0000-0000-C000-000000000046")] | ||
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); | ||
} | ||
} |
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,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
|
||
namespace DuckDNS | ||
{ | ||
class Windows | ||
{ | ||
[DllImport("shell32.dll")] | ||
static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, | ||
[Out] StringBuilder lpszPath, int nFolder, bool fCreate); | ||
const int CSIDL_STARTUP = 0x7; | ||
|
||
public static string GetStartupPath() | ||
{ | ||
StringBuilder path = new StringBuilder(260); | ||
SHGetSpecialFolderPath(IntPtr.Zero, path, CSIDL_STARTUP, false); | ||
return path.ToString(); | ||
} | ||
} | ||
} |
Binary file not shown.