-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathApp.xaml.cs
48 lines (39 loc) · 1.26 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Runtime.InteropServices;
using System.Windows;
namespace MMSaveEditor
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public string LocalLowFolderPath;
public static App Instance;
public App()
{
Instance = this;
Guid localLowId = new Guid("A520A1A4-1780-4FF6-BD18-167343C5AF16");
LocalLowFolderPath = GetKnownFolderPath(localLowId);
Localisation.LoadData();
}
string GetKnownFolderPath(Guid knownFolderId)
{
IntPtr pszPath = IntPtr.Zero;
try
{
int hr = SHGetKnownFolderPath(knownFolderId, 0, IntPtr.Zero, out pszPath);
if (hr >= 0)
return Marshal.PtrToStringAuto(pszPath);
throw Marshal.GetExceptionForHR(hr);
}
finally
{
if (pszPath != IntPtr.Zero)
Marshal.FreeCoTaskMem(pszPath);
}
}
[DllImport("shell32.dll")]
static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr pszPath);
}
}