diff --git a/UWPHook/AppManager.cs b/UWPHook/AppManager.cs index 23afe60..4e2129f 100644 --- a/UWPHook/AppManager.cs +++ b/UWPHook/AppManager.cs @@ -187,7 +187,7 @@ public static List GetInstalledApps() /// Whether this is a known app public static bool IsKnownApp(string appName, out string readableName) { - string appsJson = File.ReadAllText(@"Resources\KnownApps.json"); + string appsJson = GetEmbeddedResource("KnownApps.json"); var apps = Newtonsoft.Json.JsonConvert.DeserializeObject>(appsJson); foreach (var kvp in apps) @@ -203,6 +203,17 @@ public static bool IsKnownApp(string appName, out string readableName) return false; } + static string GetEmbeddedResource(string resourceName) + { + var assembly = Assembly.GetExecutingAssembly(); + resourceName = assembly.GetManifestResourceNames().First(r => r.Contains(resourceName)); + using (Stream stream = assembly.GetManifestResourceStream(resourceName)) + using (StreamReader reader = new StreamReader(stream)) + { + return reader.ReadToEnd(); + } + } + [DllImport("user32.dll")] private static extern bool SetForegroundWindow(IntPtr hWnd); diff --git a/UWPHook/UWPHook.csproj b/UWPHook/UWPHook.csproj index 84dc940..07fe42a 100644 --- a/UWPHook/UWPHook.csproj +++ b/UWPHook/UWPHook.csproj @@ -10,6 +10,9 @@ true false Resources\hook2.ico + true + win-x64 + true