public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool isFirstInstance; // Please use a unique name for the mutex to prevent conflicts with other programs using (Mutex mtxSpotlightDesktopWallpaper = new Mutex(true, "SpotlightDesktopWallpaper", out isFirstInstance)) { if (isFirstInstance) { MenuItem saveWallpaperItem = new MenuItem(); saveWallpaperItem.Checked = false; NotificationIcon notificationIcon = new NotificationIcon(); notificationIcon.notifyIcon.Visible = true; RegistryKey saveWallpaper = Registry.CurrentUser.OpenSubKey("SOFTWARE\\SpotlightDesktopWallpaper", true); if (saveWallpaper.GetValue("SaveWallpaper") != null) { saveWallpaperItem.Checked = true; } ApplicationContext wallpaperApplicationContext = new wallpaperApplicationContext(saveWallpaperItem); Application.Run(); notificationIcon.notifyIcon.Dispose(); } else { MessageBox.Show("SpotlightDesktopWallpaper is already running!", "SpotlightDesktopWallpaper"); } } // releases the Mutex }
private void OnRegChanged(object sender, EventArgs e) { ApplicationContext wallpaperApplicationContext = new wallpaperApplicationContext((notificationMenu.MenuItems[1])); }