private void ThisAddIn_Startup(object sender, System.EventArgs e) { //Configure logging log4net.Config.XmlConfigurator.Configure(); try { log.Info("Add-in startup"); log.DebugFormat("OS: {0} {1}", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "x64" : "x86"); log.DebugFormat("Outlook version: {0} {1}", this.Application.Version, Environment.Is64BitProcess ? "x64" : "x86"); log.DebugFormat("Language: {0}", Application.LanguageSettings.get_LanguageID(Microsoft.Office.Core.MsoAppLanguageID.msoLanguageIDUI)); //Set up exception handlers System.Windows.Forms.Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; //Start cleanup timer int cleanupTimerInterval = int.Parse(System.Configuration.ConfigurationManager.AppSettings["CleanupTimerInterval"]); log.InfoFormat("Starting cleanup timer -- run every {0} minutes", cleanupTimerInterval); cleanupTimer = new System.Threading.Timer(CleanupTimer_Callback, null, 0, cleanupTimerInterval * 60 * 1000); //Start hook; hook = new DragDropHook(); hook.Start(); } catch (Exception ex) { log.Fatal("Fatal error", ex); if (hook != null) { hook.Stop(); } } }
private void StopHook() { //Stop hooking drag and drop if (Hook != null) { Hook.Dispose(); Hook = null; } }
private void StartHook() { //Start hooking drag and drop if (Hook == null) { Hook = new DragDropHook(); Hook.StartHook(); } }