static void Main(string[] args) { //util.test_normalized_times(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // uncomment this to test how we'd behave in release // util.is_debug = false; util.set_current_dir(); util.init_log(); string sett_file = util.is_debug ? "logwizard_debug" : "logwizard_user"; util.create_backup(sett_file, ".txt", 15); app.inst.init(new settings_file(sett_file + ".txt")); util.force_break_into_debugger(); util.init_exceptions(); // if "Open With" and LogWizard is already running -> send this to the existing running application // the reason for this: if multiple instances running, they can mess up the settings file - we don't want that! if (!util.is_debug) { var running_already = Process.GetProcessesByName("LogWizard").ToDictionary(x => x.Id, x => x); running_already.Remove(Process.GetCurrentProcess().Id); if (running_already.Count > 0) { // there's another instance running if (args.Length == 0) { // just let the other instance run return; } // for the other instance - what to open string open = args[0]; var cds = new win32.COPYDATASTRUCT { dwData = new IntPtr(0), cbData = open.Length * 2 + 1, lpData = open }; var handle = running_already.First().Value.MainWindowHandle; win32.SendMessage(handle, win32.WM_COPYDATA, IntPtr.Zero, ref cds); return; } } if (args.Length > 0 && File.Exists(args[0])) { open_file_name_ = args[0]; } if (open_file_name_ != null) { wait_for_setup_kit_to_complete(); } Application.Run(new Dummy()); }
static void Main(string[] args) { //util.test_normalized_times(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // uncomment this to test how we'd behave in release // util.is_debug = false; util.set_current_dir(); util.init_log(); string sett_file = util.is_debug ? "logwizard_debug" : "logwizard_user"; util.create_backup(sett_file, ".txt", 15); app.inst.init(new settings_file(sett_file + ".txt")); util.force_break_into_debugger(); util.init_exceptions(); // if "Open With" and LogWizard is already running -> send this to the existing running application // the reason for this: if multiple instances running, they can mess up the settings file - we don't want that! if (!util.is_debug) { var running_already = Process.GetProcessesByName("LogWizard").ToDictionary(x => x.Id, x => x); running_already.Remove(Process.GetCurrentProcess().Id); if (running_already.Count > 0) { // there's another instance running if (args.Length == 0) { // just let the other instance run return; } // for the other instance - what to open string open = args[0]; var cds = new win32.COPYDATASTRUCT { dwData = new IntPtr(0), cbData = open.Length * 2 + 1, lpData = open }; var handle = running_already.First().Value.MainWindowHandle; win32.SendMessage(handle, win32.WM_COPYDATA, IntPtr.Zero, ref cds); return; } } if (args.Length > 0 && args[0] == "showsample") { try { Process.Start(Assembly.GetExecutingAssembly().Location, new FileInfo("LogWizardSetupSample.log").FullName); } catch (Exception e) { MessageBox.Show("Exception " + e.Message); } return; } if (args.Length > 0 && File.Exists(args[0])) { open_file_name_ = args[0]; } if (open_file_name_ != null) { wait_for_setup_kit_to_complete(); } if (!util.is_debug) { util.set_association(".log", "Log_file", Application.ExecutablePath, "Log File"); util.set_association(".txt", "Text_file", Application.ExecutablePath, "Text File"); // 1.1.5+ util.set_association(".zip", "Zip_file", Application.ExecutablePath, "Zip File"); util.set_association(".logwizard", "LogWizard_file", Application.ExecutablePath, "LogWizard File"); util.create_shortcut("LogWizard", appdata_dir() + @"Microsoft\Windows\SendTo", "Send To LogWizard", null, Application.ExecutablePath, null); } Application.Run(new Dummy()); }