From 1ed03a2a79ae361ec2a96e606f500126a533dcf8 Mon Sep 17 00:00:00 2001 From: rjindael Date: Mon, 31 Jul 2023 05:41:06 -0700 Subject: [PATCH] feat: remove giant dependency --- .../Kiseki.Launcher.Windows.csproj | 4 ---- Kiseki.Launcher.Windows/Launcher.cs | 4 +--- Kiseki.Launcher.Windows/Win32.cs | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 Kiseki.Launcher.Windows/Win32.cs diff --git a/Kiseki.Launcher.Windows/Kiseki.Launcher.Windows.csproj b/Kiseki.Launcher.Windows/Kiseki.Launcher.Windows.csproj index 1517034..f0d573b 100644 --- a/Kiseki.Launcher.Windows/Kiseki.Launcher.Windows.csproj +++ b/Kiseki.Launcher.Windows/Kiseki.Launcher.Windows.csproj @@ -45,8 +45,4 @@ - - - - \ No newline at end of file diff --git a/Kiseki.Launcher.Windows/Launcher.cs b/Kiseki.Launcher.Windows/Launcher.cs index fda193f..e2ce691 100644 --- a/Kiseki.Launcher.Windows/Launcher.cs +++ b/Kiseki.Launcher.Windows/Launcher.cs @@ -2,8 +2,6 @@ using System.Reflection; using Microsoft.Win32; -using Syroot.Windows.IO; - namespace Kiseki.Launcher.Windows { public class Launcher : ILauncher @@ -58,7 +56,7 @@ namespace Kiseki.Launcher.Windows { Title = "Select your license file", Filter = "License files (*.bin)|*.bin", - InitialDirectory = KnownFolders.Downloads.Path + InitialDirectory = Win32.GetDownloadsPath() }; if (dialog.ShowDialog() == DialogResult.OK) diff --git a/Kiseki.Launcher.Windows/Win32.cs b/Kiseki.Launcher.Windows/Win32.cs new file mode 100644 index 0000000..39934a5 --- /dev/null +++ b/Kiseki.Launcher.Windows/Win32.cs @@ -0,0 +1,16 @@ +using System.Runtime.InteropServices; + +namespace Kiseki.Launcher.Windows +{ + public static class Win32 + { + [DllImport("shell32", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false)] + private static extern string SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, nint hToken = default); + + // https://www.codeproject.com/Articles/878605/Getting-All-Special-Folders-in-NET + public static string GetDownloadsPath() + { + return SHGetKnownFolderPath(new("374DE290-123F-4565-9164-39C4925E467B"), 0); + } + } +} \ No newline at end of file