|
6 | 6 | using System.Windows.Media; |
7 | 7 | using System.Threading.Tasks; |
8 | 8 | using System.Windows.Controls; |
9 | | -using System.Runtime.InteropServices; |
10 | | -using System.Windows.Forms.Integration; |
11 | 9 | using Windows.Management.Deployment; |
| 10 | +using System.Windows.Forms.Integration; |
12 | 11 |
|
13 | 12 | class MainWindow : Window |
14 | 13 | { |
15 | | - [DllImport("Kernel32", CharSet = CharSet.Auto, SetLastError = true)] |
16 | | - [DefaultDllImportSearchPaths(DllImportSearchPath.System32)] |
17 | | - internal static extern bool DeleteFile(string lpFileName); |
18 | | - |
19 | | - [DllImport("Shell32", CharSet = CharSet.Auto, SetLastError = true)] |
20 | | - internal static extern IntPtr ShellExecute(IntPtr hwnd = default, string lpOperation = null, string lpFile = null, string lpParameters = null, string lpDirectory = null, int nShowCmd = 0); |
21 | | - |
22 | 14 | enum Units { B, KB, MB, GB } |
23 | 15 |
|
24 | 16 | static string Format(float bytes) |
@@ -127,7 +119,7 @@ internal MainWindow(bool preview) |
127 | 119 | client.CancelAsync(); |
128 | 120 | while (client.IsBusy) ; |
129 | 121 | operation?.Cancel(); |
130 | | - DeleteFile(packageUri?.AbsolutePath); |
| 122 | + NativeMethods.DeleteFile(packageUri?.AbsolutePath); |
131 | 123 | foreach (var package in Store.PackageManager.FindPackagesForUserWithPackageTypes(string.Empty, PackageTypes.Framework)) |
132 | 124 | _ = Store.PackageManager.RemovePackageAsync(package.Id.FullName); |
133 | 125 | }; |
@@ -161,11 +153,11 @@ internal MainWindow(bool preview) |
161 | 153 | operation.Progress += (sender, e) => Dispatcher.Invoke(() => { if (progressBar.Value != e.percentage) textBlock1.Text = $"Installing {progressBar.Value = e.percentage}%"; }); |
162 | 154 | operation.AsTask().Wait(); |
163 | 155 | } |
164 | | - finally { DeleteFile(packageUri.AbsolutePath); } |
| 156 | + finally { NativeMethods.DeleteFile(packageUri.AbsolutePath); } |
165 | 157 | } |
166 | 158 | } |
167 | 159 |
|
168 | | - ShellExecute(lpFile: @$"shell:AppsFolder\Microsoft.Minecraft{(preview ? "WindowsBeta" : "UWP")}_8wekyb3d8bbwe!App"); |
| 160 | + NativeMethods.ShellExecute(lpFile: @$"shell:AppsFolder\Microsoft.Minecraft{(preview ? "WindowsBeta" : "UWP")}_8wekyb3d8bbwe!App"); |
169 | 161 | Dispatcher.Invoke(Close); |
170 | 162 | }); |
171 | 163 | } |
|
0 commit comments