public App() { FileInfo StartupFile = new FileInfo(Process.GetCurrentProcess().MainModule.FileName); //Install the app string StartupLink = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "Blaze IM.lnk"); string StartMenuLink = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Blaze IM.lnk"); string AppdataLink = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlazeGamesIM", "BlazeIM.exe"); if (AppdataLink != StartupFile.FullName && !StartupFile.Name.Contains("vshost")) { try { if (File.Exists(StartupLink)) { File.Delete(StartupLink); } if (File.Exists(StartMenuLink)) { File.Delete(StartMenuLink); } if (File.Exists(AppdataLink)) { File.Delete(AppdataLink); } File.Copy(StartupFile.FullName, AppdataLink); IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell(); IWshRuntimeLibrary.IWshShortcut StartMenuShortcut; StartMenuShortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(StartMenuLink); StartMenuShortcut.TargetPath = AppdataLink; StartMenuShortcut.Description = "Launch Blaze IM"; StartMenuShortcut.Save(); IWshRuntimeLibrary.IWshShortcut StartupShortcut; StartupShortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(StartupLink); StartupShortcut.TargetPath = AppdataLink; StartupShortcut.Description = "Launch Blaze IM"; StartupShortcut.Save(); } catch { } } if (ApplicationRunningHelper.AlreadyRunning() && !StartupFile.Name.Contains("vshost")) { Application.Current.Shutdown(); return; } if (ConfigManager.Instance.GetBool("indev", false)) { ConsoleWindow consolewnd = new ConsoleWindow(); ConsoleLog log = new ConsoleLog(Console.Out); Console.SetOut(log); consolewnd.Show(); } ApplicationStartTick = Environment.TickCount & Int32.MaxValue; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; Instance = this; Startup += App_Startup; DirectoryInfo chatlogs_di = new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlazeGamesIM", "ChatLogs")); if (!chatlogs_di.Exists) { chatlogs_di.Create(); } try { if (!StartupFile.Name.Contains("vshost")) { byte[] file_data = File.ReadAllBytes(StartupFile.FullName); MD5Hash = BlazeGames.IM.Client.Core.Utilities.MD5(file_data); } } catch { } WeatherApi weatherApi = new WeatherApi("Caldwell Idaho"); weatherApi.WeatherDataUpdated += weatherApi_WeatherDataUpdated; }
public App() { FileInfo StartupFile = new FileInfo(Process.GetCurrentProcess().MainModule.FileName); //Install the app string StartupLink = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "Blaze IM.lnk"); string StartMenuLink = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Blaze IM.lnk"); string AppdataLink = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlazeGamesIM", "BlazeIM.exe"); if (AppdataLink != StartupFile.FullName && !StartupFile.Name.Contains("vshost")) { try { if (File.Exists(StartupLink)) File.Delete(StartupLink); if (File.Exists(StartMenuLink)) File.Delete(StartMenuLink); if (File.Exists(AppdataLink)) File.Delete(AppdataLink); File.Copy(StartupFile.FullName, AppdataLink); IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell(); IWshRuntimeLibrary.IWshShortcut StartMenuShortcut; StartMenuShortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(StartMenuLink); StartMenuShortcut.TargetPath = AppdataLink; StartMenuShortcut.Description = "Launch Blaze IM"; StartMenuShortcut.Save(); IWshRuntimeLibrary.IWshShortcut StartupShortcut; StartupShortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(StartupLink); StartupShortcut.TargetPath = AppdataLink; StartupShortcut.Description = "Launch Blaze IM"; StartupShortcut.Save(); } catch { } } if (ApplicationRunningHelper.AlreadyRunning() && !StartupFile.Name.Contains("vshost")) { Application.Current.Shutdown(); return; } if (ConfigManager.Instance.GetBool("indev", false)) { ConsoleWindow consolewnd = new ConsoleWindow(); ConsoleLog log = new ConsoleLog(Console.Out); Console.SetOut(log); consolewnd.Show(); } ApplicationStartTick = Environment.TickCount & Int32.MaxValue; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; Instance = this; Startup += App_Startup; DirectoryInfo chatlogs_di = new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlazeGamesIM", "ChatLogs")); if (!chatlogs_di.Exists) chatlogs_di.Create(); try { if (!StartupFile.Name.Contains("vshost")) { byte[] file_data = File.ReadAllBytes(StartupFile.FullName); MD5Hash = BlazeGames.IM.Client.Core.Utilities.MD5(file_data); } } catch { } WeatherApi weatherApi = new WeatherApi("Caldwell Idaho"); weatherApi.WeatherDataUpdated += weatherApi_WeatherDataUpdated; }